Live data from Hacker News

Ask HN: How do you maintain personal annotations for code you don't control?

news.ycombinator.com

31–40 of 45 posts

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#31
I keep comments committed in a separate branch.

The lack of syncing doesn't bother me, because the purpose of taking notes always falls into one of these categories:

1. I read the code to get an idea of how something works. The code is there to make examples/variable names concrete, but I don't need to know the exact implementation.

If the notes need to sit in the code, usually that's because the answer spans multiple methods (eg "what does an e2e request look like?"). A set of comments on outdated code is always good enough for me.

Otherwise, a lot of times the answer can be summarized in one line (eg "where is the state tracked?" -> in FooBarClass). These can go into personal notes.

2. I need to know the implementation and it is complex and hard to follow.

If I need to know the implementation, either it is because I'm actively working on it, or I need to make [complex idea] more concrete in my head.

If it's the former, usually I'll have memorized it by the time I read through it.

If it's the latter, by the end of it I'll have gotten the main idea and it's fine to forget the implantation details.

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#32

This is the first time I've ever heard of someone keeping private source-line-attached notes in a codebase. I work with very large codebases, but if I discover things about the codebase that required spelunking, I generally turn them into comments or documentation. Of the requirements that you've laid out, I'd suggest that you need to either relax requirement 2 or 3: If you relax requirement 2, you could keep your no…

You wouldn't even need to relax requirement 2 too much, rebasing your commented fork on the trunk would actually help you keep your comments up to date.

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#33
post #18
post #17

Earlier quoted context omitted.

Is this what GitHub reviews use?

No, they're unrelated.

But wouldn’t it be nice if they were stored in git notes? It’ll never happen for a commercial git hosting product, because they want it to be hard to leave their service (you lose your PR review comment history), and storing them in git makes it too easy to migrate all your history to a competitor.

Building an open source code review system using git notes would be great though.

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#35
I teach a class on computer graphics, where I want to embed my working source code into my web based explanations, so perhaps the following could help you

I have my source code in one directory, and in another I use Sphinx to make the documentation. In the documentation, I reference certain sections of code, which you can do by line number, or you can do by some pattern to begin and end.

Since I control all my source code, I put in comments with certain flags for regions of code.

I can then reference said section of code as follows

  .. literalinclude:: ../../src/demo06/demo.py
     :language: python
     :start-after: doc-region-begin define uniform scale
     :end-before: doc-region-end define uniform scale
     :linenos:
     :lineno-match:
     :caption: src/demo06/demo.py
https://github.com/billsix/modelviewprojection/blob/master/b...

The generated book is here https://billsix.github.io/modelviewprojection/

For your purposes, using a third party's code, I would make a new git repository, and copy the current status of their code in, I would then annotate the sections that I want to with comments, And then generate the documentation using Sphinx, referencing you annotations of their code

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#36
Coincidentally, I'm in the middle [1] of building something for https://CoCalc.com that is exactly what you're describing. For collaborative document editing (e.g., google drive and overleaf) it's a common feature, but for code editors it isn't. CoCalc is both. Anyway, nothing to see yet, but you might want to check with us in a month. After thinking about this problem a lot recently, I think it’s critical to store the comment locations with all versions of the file, so you don’t lose comment locations, or at least maximize the information you have available to locate comments when they get lost.

[1] https://github.com/sagemathinc/cocalc/pull/8071

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#39
I would like to see (better) solutions not only for source code, but general web-pages and applications. For example, bookmarks in a browser are ok, but it would be a lot better if you could easily annotate and later reference / rank / prioritize. A browser is a pretty good proxy to the world's knowledge including source code. It be nice if they would level up in these regards.

There are tools for aspects of all these areas, but still feel unsolved (easy, feature-full).

Re: Ask HN: How do you maintain personal annotations for code you don't control?

#40
post #28
post #3

Leo editor allows to keep in sync its outline which combines your annotations and external files. Obviously it isn't bulletproof and needs maintenance when it can't merge external changes automatically. https://leo-editor.github.io/leo-editor/

I came here to post this. To expand: With Leo editor, you convert the document/file into a tree of nodes (one way to do this is to make each function a node - they have plugins to do it automatically for well known languages like C++). Let's say you make a particular function a node. You can then make a new document in your own filesystem which has your notes, but you can make a "live" copy of the node linking to tha…

> It's the one powerful feature that has yet to be replicated in Emacs.

Emacs cannot do this. There are many Emacs libraries or packages that need this feature (Org babel is a big one, transclusion is another), and have to work around its absence in hacky ways.

Post reply on HN