Live data from Hacker News

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

news.ycombinator.com

1–10 of 45 posts

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

#1
I spend significant time reading and understanding codebases that I don't control (open source libraries, internal legacy systems, etc.). As I build understanding, I need to document my insights, gotchas, and mental models - but these notes are purely personal and shouldn't be part of the actual codebase.

My challenges:

1. These annotations need to be tightly coupled with specific locations in the source code (particular functions, variables, or even specific lines)

2. The underlying code changes regularly (new versions, updates from maintainers) which can break the connection between my notes and the code

3. My notes are private - they include half-formed thoughts, questions, and sometimes critical observations that wouldn't be appropriate as public comments

4. I want to preserve this knowledge across different machines and working environments

I've tried various approaches: - Local IDE bookmarks (lost between sessions) - Separate markdown files (hard to maintain precise code references) - Private forks with comments (becomes unmaintainable as source evolves)

I'm curious how others solve this problem. Do you have a systematic approach for maintaining personal annotations on code that's not under your control? How do you handle the challenge of the code evolving while keeping your notes relevant?

Would especially love to hear from people working with large codebases or those who regularly need to dive deep into external dependencies.

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

#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/

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

#4
post #2

> Private forks with comments (becomes unmaintainable as source evolves) If swdev-grade merging tools are not sufficient to get it done then that's probably a bad sign for your requirements being possible to be met

That's a good point. Good enough but a pain. I was hoping for something more tailored to my usecase.

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

#5
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 notes in a private fork.

If you relax requirement 3, and make your notes suitable for public consumption, you could submit your notes as comments and make the codebase easier for everyone to understand. (Or, at least, you could submit some of your comments, making the remainder easier to maintain privately.)

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

#6
The closest I've come to doing something like this is commenting poorly-commented code, and keeping my in-progress comments in a branch that I regularly rebase.

You said that becomes unmaintainable as the source evolves, but that's surely a fundamental property of keeping notes on changing code? You have to do work keeping your private comments up to date with any method.

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

#7
GitHub issue comments. You can link to code in GitHub that's anchored to a specific commit. If it's in the same repo GitHub will inline the code into the issue git you. For separate repos I sometimes link and then manually copy in the code block myself.

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

#8
you describe a nightmare. which the only solution is to keep one single commit with all the comments on a branch.

update and rebase the branch. solve conflicts if they changed code around the comments. anything else you will be just delaying this exact same chore and possibly making it impossible down the road.

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

#9
I recently came across a VS Code extension that does pretty much what you're looking for -

> Out-of-Code Insights is a Visual Studio Code extension that allows you to add annotations, notes, and comments without modifying your source files.

https://marketplace.visualstudio.com/items?itemName=JacquesG...

GitHub:

https://github.com/JacquesGariepy/out-of-code-insights/

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

#10

I recently came across a VS Code extension that does pretty much what you're looking for - > Out-of-Code Insights is a Visual Studio Code extension that allows you to add annotations, notes, and comments without modifying your source files . https://marketplace.visualstudio.com/items?itemName=JacquesG... GitHub: https://github.com/JacquesGariepy/out-of-code-insights/

Neat, I was looking for something like that from some time.
Post reply on HN