News for hackers. Stuff that matters.
Re:Diagram as Code by kovek on Tuesday May 12, 2020 @01:42PM (#23157007)
This is cool! I was hoping it would look something like:

‘’’ import diagrams calc_d = diagrams.new_diagram(“calculator_123”)

calc_d.Datum("SuperNumber") class SuperNumber(int): pass

@calc_d.Service(“Calculator”, “takes numbers and operations and operates”) class Calculator(object): @calc_d.Endpoint("Add", calls=["Increment"], main_data={"b": "SuperNumber}) def add(self, a, b: SuperNumber): out = a for i in range(b): calc_d.multi(calls=["Increment"]) out = self.increment(out)

  @calc_d.Function("Increment")
  def increment(self, a):
    return a+1
def integration_test(): calc_d.instantiate("Calculator") calc = Calculator() ... ‘’’

EDIT: Dear dang and YC Hacker News, I would love to create code blocks using surrounding triple quotes..

Re:Diagram as Code by kitd on Tuesday May 12, 2020 @03:54PM (#23158892)
Indent with 4 spaces at the start of each line for code blocks.
Re:Diagram as Code by anamexis on Tuesday May 12, 2020 @03:55PM (#23158903)
This is annoyingly difficult in a browser.
Re:Diagram as Code by Allezxandre on Tuesday May 12, 2020 @04:58PM (#23159715)
Just copy the text and use `sed` on your clipboard to transform your text.

On macOS:

    pbpaste | sed 's/^.*$/    &/' | pbcopy
Re:Diagram as Code by yesenadam on Tuesday May 12, 2020 @06:13PM (#23160676)
Perhaps it's more readable/writeable with Awk:

    pbpaste | awk '{print "    "$0}' | pbcopy
Although this also seems to do the same thing

    pbpaste | sed 's/^/    &/' | pbcopy
Re:Diagram as Code by kovek on Tuesday May 12, 2020 @07:43PM (#23161503)
For anyone finding a solution to code blocks... I write these comments from Safari on my iPhone