5 ms·
This [0] is one of my all time favourite comments. Chris Wilson explains how the stroke miter limit works in cairio graphics through the medium of ascii art (an
by aidos 8y ago
This [0] is one of my all time favourite comments. Chris Wilson explains how the stroke miter limit works in cairio graphics through the medium of ascii art (and tidy maths).
[0] https://github.com/behdad/cairo/blob/color-emoji/src/cairo-path-stroke-polygon.c#L419 https://github.com/behdad/cairo/blob/color-emoji/src/cairo-p...
- 2Pacalypse- 8y agoHa! That's pretty neat. I also resort to ASCII art comments, when appropriate: https://github.com/ShieldBattery/node-interval-tree/blob/master/index.ts#L82 https://github.com/ShieldBattery/node-interval-tree/blob/mas...
- willvarfar 8y agoWhat a lovely comment, explaining not just the why but also, in this case, the 'how' because its not obvious how to derive the code from the requirement so actually explaining how is worth it. But then I scrolled down and saw it verbatim just a few lines further down https://github.com/behdad/cairo/blob/color-emoji/src/cairo-path-stroke-polygon.c#L603 https://github.com/behdad/cairo/blob/color-emoji/src/cairo-p... Why is CheckMitreHight() not a function? :)
- aidos 8y agoAnd a bunch of other places in the codebase from memory (cairo-path-stroke.c, cairo-path-stroke-polygon.c and cairo-path-stroke-tristrip.c). And there's a bug in there too because they're working in the wrong space so the checks are applied after outer transformations [0].... but it's still a great comment! :-) [0] https://bugs.freedesktop.org/show_bug.cgi?id=100703 https://bugs.freedesktop.org/show_bug.cgi?id=100703
- criddell 8y agoI wish my IDE could interpret a special comment like /* img "doc/uml.png" */ or something similar that it would use to display an image inline with my source code. There are so many times I've created a FSM diagram with graphviz + dot that I'd love to include inline.
- FroshKiller 8y agoIsn't that a feature of TempleOS? You can embed any content in any file, including images in source code?
- AlexeyBrin 8y agoEmacs can do it, see https://stackoverflow.com/questions/15759901/insert-a-picture-in-code-comment-via-emacs https://stackoverflow.com/questions/15759901/insert-a-pictur... I'm sure you can find similar extensions for VSCode or Atom.
- tobych 8y agoJetBrains IDEs can do almost this using the PlantUML plugin (see my comment above): you just have to write a little graphml code to show the PNG. It's not inline with the source code, but in a separate pane. But a documentation generator (such as Sphinx) could show the image inline, with a little plugin.
- criddell 8y agoI have done this with a documentation generator (doxygen) but I want it in Visual Studio. There is a plugin for it, but it's pretty buggy. It would be nice if it were a core capability.
- piyush_soni 8y agoA few times I had to do that in the past, I searched for some utility online that could convert my line diagram to ASCII art, and failed (so had to do it myself). Anyone knows if such a thing exists?
- tobych 8y agoNot line-art to ASCII art, so not exactly what you're looking for, but PlantUML [1] generates software-related diagrams from ASCII text. There's a plug-in for JetBrains IDEs such as PyCharm that will render the diagram in a pane in the IDE: you can include the ASCII text in a comment in code. You can also generate documentation (I use Sphinx, for Python stuff) that includes diagrams generated from code. [1] http://plantuml.com/ http://plantuml.com/