doc: add styleguide#41025
Conversation
|
I'll update this tomorrow with a definition on how to fit in the Changelog section in Markdown rather than YAML. Wanted to get this up ASAP, though :) |
|
Improved line lengths, ran |
|
@nodejs/documentation |
|
@bnb, this PR is confusing to me since I was not part of this discussion — it seems like this is the result of some @nodejs/next-10 discussions that took place recently, but perhaps even more recently was another discussion had by myself, @GeoffreyBooth, and @Trott… We are currently using the Microsoft Docs styleguide — would anyone like to explain why the change? I am not necessarily opposed to a change, but this seems to be contrary to what we have been using so far… |
| [nodejs/remark-preset-lint-node]: https://github.com/nodejs/remark-preset-lint-node | ||
| [remark-preset-lint-node]: https://www.npmjs.com/package/remark-preset-lint-node | ||
| [sentence-case]: https://apastyle.apa.org/style-grammar-guidelines/capitalization/sentence-case | ||
| [title-case]: https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case |
There was a problem hiding this comment.
I am +1 to using title case for titles.
I still haven't figured out why we have not been using this from the beginning other than wanting to do what MDN does, which doesn't seem properly justified.
|
|
||
| The following rules only apply to the documentation of APIs. | ||
|
|
||
| ### Title and description |
There was a problem hiding this comment.
| ### Title and description | |
| ### Title and Description |
APA title case would need to be applied to all of these titles.
How can we lint for this? I would like to do so.
There was a problem hiding this comment.
APA title case would need to be applied to all of these titles.
This is not the title of the page and per the text above, should be sentence case.
There was a problem hiding this comment.
You are correct in that this not being the title of the page; however, it is the title of a section of the page. We can call them “chapters” as @bnb proposes.
Other words for this could be “segments”, “sections”, etc…
|
This feels like a very big change, essentially a rewrite/reformatting of all of Node’s documentation. While making the docs more parseable for type definitions is a worthy goal, I’m not sure that the level of effort required here justifies that payoff. I’m also a big fan of the policy that we just follow the Microsoft Style Guide and that’s it, and we spare ourselves debates over style questions. Adopting our own styleguide would seem to invite such debates. Maybe this was already discussed within Next-10 and raised to the TSC, but I think if this is something that the project wants to pursue it should be debated and approved by the TSC. cc @Trott, @nodejs/tsc |
Trott
left a comment
There was a problem hiding this comment.
We already have a documentation style guide. https://github.com/nodejs/node/blob/e601c0d678f815e00c385c5b5b3b9efd6bcaaf91/doc/guides/doc-style-guide.md
We should not have two duplicative style guides and we should certainly not have two contradictory style guides.
|
|
||
| There are a few style guidelines that aren't covered by the linter rules: | ||
|
|
||
| * Use `sh` instead of `cmd` in code blocks (due to the syntax highlighter). |
There was a problem hiding this comment.
The text says this isn't covered by the linter rules, but it in fact is.
|
|
||
| * Use `sh` instead of `cmd` in code blocks (due to the syntax highlighter). | ||
| * Keep line lengths between 80 and 100 characters if possible for readability | ||
| purposes. |
There was a problem hiding this comment.
The linter (mostly) enforces 80 character wrapping so this too is enforced by the linter but the text above says it isn't.
| purposes. | ||
| * No nesting lists more than 2 levels (due to the markdown renderer). | ||
| * All `js` and `javascript` code blocks are linted with | ||
| [standard-markdown](https://www.npmjs.com/package/standard-markdown). |
This PR adds a documentation style guide. This comes as a result of https://github.com/nodejs/node/discussions/40953 and the various next-10 discussions that led to it. It is largely a copy/paste from electron/electron's styleguide.md, with some changes.
The goal of this is not to have it as an immediately enforceable, but rather to have it be planted as the guide that we'll eventually fully enforce on all documentation that it can be enforced on (some documentation, like native APIs, it can only be partially enforced on).
Landing this and, eventually, having all of our documentation written in this style should allows us the ability to use docs-parser which produces a high-quality JSON output of markdown documentation written as the style guide defines. This would allow the DefinitelyTyped people to produce higher quality type definitions, potentially even just using Electron's typescript-definitions tooling that parses docs-parser output into
.d.tsfiles.There are other, less objective benefits:
Worth noting, I also created #32206 some time ago, and this is one step towards that as a reality. In doing so, I also created bnb/node-docs-parser which snapshotted a few examples from the Node.js documentation at the time I created it and provided an example of what those documents would look like if they were migrated. While it's been a pandemic worth of time since I last worked on that repo and some of the docs have been updated (querystring in particular is much more consistent!), the documents in
/docs/apiare still pretty close to what the "translated" versions would look like if you want a reference.changes to the styleguide.md from the e/e version include:
Electron>Node.js)markdownlinta few things to discuss:
and just for context, the ideal next steps after this PR lands would be to begin incrementally migrating documentation to fit the style guide.