by christophilus · 4y ago · 0 comments
They get orphaned by slightly wonky merges. The underlying code gets updated or refactored, but the comments remain. When they are correct, they’re useless 90% of the time (at least in codebases whose linter requires doc comments). Even the accurate comments tend to drift with age and become inaccurate unless they’re carefully maintained (which they almost never are).
It’s really hard for me to figure out the balance.
For exceptionally good codebases (Redis, SQLite come to mind), the comments are a godsend.
For mediocre codebases, the comments are largely a waste of time at best, misleading and time-wasting at worst. And most of us, I suspect, are working on mediocre codebases.
At least classes and public methods should have comments (except trivial ones).
[1] https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDateT...
Something like this with a discrete task that can be checked on code review would help immensely, I think.
> Rustdoc actually uses the rustc internals directly. It lives in-tree with the compiler and standard library. This chapter is about how it works. For information about Rustdoc's features and how to use them, see the Rustdoc book. For more details about how rustdoc works, see the "Rustdoc internals" chapter.
docs.rs runs it for every crate (rust library) uploaded to crates.io.
When actually working with rust, I recommend running `cargo doc --open` semi frequently. It generates that documentation from all your dependencies, and your own code, links it all together (with search no less) and opens it in a browser.
Note that it only uses doc comments, which are distinct from normal comments (/// instead of //, only allowed in certain places, //! Instead of /// to apply to the parent item instead of the next item).
Adding a mechanism to publish the docs (maybe part of CI/CD?) would make maintenance way easier, it's something I would love to test out.
Not much time to work on it lately. But, I’ll Show HN when I put it on Github.
Bad codebases are ones that basically are throwaway or depreciating assets. As you say, we practically all work on these except the lucky few.