marginalia icon indicating copy to clipboard operation
marginalia copied to clipboard

How to handle nested comments?

Open budu opened this issue 13 years ago • 9 comments

With the latest fix for the parser, it now has been improved to handle top-level versus nested comments. For the moment, it leaves them untouched. I wonder if we could make Marginalia do something clever with them, any suggestions?

budu avatar Jan 19 '11 19:01 budu

By nested, do you mean this:

;; this is top-level
(defn foo [x]
    ;; this is nested
    42)

??

fogus avatar Jan 25 '11 16:01 fogus

Yes, exactly! We can just not care about them, but the latest changes to the parser add the possibility to do something with them.

budu avatar Jan 25 '11 16:01 budu

My view is:

(defn foo [x]
  ;; sub-comments alone on a line go to the doc view (left-side)
  (let [x (int x)]  ;; comments at the end of code stay in the code (right-side)
    x))

What do you think?

fogus avatar Jan 25 '11 16:01 fogus

Seems reasonable, but for the lone sub-comments, do we just append it to the current code block docs or do we split the code block? The first case should be easier to implement, the second have the advantage of keeping the comment aligned with it's content.

budu avatar Jan 25 '11 17:01 budu

Keeping the comment aligned with its content is the way that Docco works, so there is no reason to change that I think. You can see how Docco does it at http://jashkenas.github.com/docco/#section-11

fogus avatar Jan 25 '11 17:01 fogus

Look nice, I'm all for it, shouldn't be that hard to implement anyway.

budu avatar Jan 25 '11 17:01 budu

Excellent. I'm looking forward to seeing it.

fogus avatar Jan 25 '11 17:01 fogus

I'll probably work on this only next week as I've started a new contract and I'm pretty busy this week. Also I'd like to test Marginalia output on Pallet, Hugo told me about some issues with it's project output.

budu avatar Jan 25 '11 17:01 budu

@budu you can scratch this one off of your todo list

gdeer81 avatar Nov 10 '17 05:11 gdeer81