Browse Source

Colorize API stabilitity index headers in docs

Noted in @shtylman's #3898, API stability notes are easy to overlook
in the html documentation. This can be especially troublesome if the API
is deprecated. This commit gives visual feedback by adding in a class
to the html docs when they're generated. The API headers with
corresponding colors are also listed in the 'About this Documentation'
page for easy reference.
v0.9.5-release
Luke Arduini 12 years ago
committed by isaacs
parent
commit
192192a09e
  1. 34
      doc/api/documentation.markdown
  2. 24
      doc/api_assets/style.css
  3. 10
      tools/doc/html.js

34
doc/api/documentation.markdown

@ -31,32 +31,46 @@ proven, and so relied upon, that they are unlikely to ever change at
all. Others are brand new and experimental, or known to be hazardous all. Others are brand new and experimental, or known to be hazardous
and in the process of being redesigned. and in the process of being redesigned.
The notices look like this:
Stability: 1 Experimental
The stability indices are as follows: The stability indices are as follows:
* **0 - Deprecated** This feature is known to be problematic, and changes are ```
Stability: 0 - Deprecated
This feature is known to be problematic, and changes are
planned. Do not rely on it. Use of the feature may cause warnings. Backwards planned. Do not rely on it. Use of the feature may cause warnings. Backwards
compatibility should not be expected. compatibility should not be expected.
```
* **1 - Experimental** This feature was introduced recently, and may change ```
Stability: 1 - Experimental
This feature was introduced recently, and may change
or be removed in future versions. Please try it out and provide feedback. or be removed in future versions. Please try it out and provide feedback.
If it addresses a use-case that is important to you, tell the node core team. If it addresses a use-case that is important to you, tell the node core team.
```
* **2 - Unstable** The API is in the process of settling, but has not yet had ```
Stability: 2 - Unstable
The API is in the process of settling, but has not yet had
sufficient real-world testing to be considered stable. Backwards-compatibility sufficient real-world testing to be considered stable. Backwards-compatibility
will be maintained if reasonable. will be maintained if reasonable.
```
* **3 - Stable** The API has proven satisfactory, but cleanup in the underlying ```
Stability: 3 - Stable
The API has proven satisfactory, but cleanup in the underlying
code may cause minor changes. Backwards-compatibility is guaranteed. code may cause minor changes. Backwards-compatibility is guaranteed.
```
* **4 - API Frozen** This API has been tested extensively in production and is ```
Stability: 4 - API Frozen
This API has been tested extensively in production and is
unlikely to ever have to change. unlikely to ever have to change.
```
* **5 - Locked** Unless serious bugs are found, this code will not ever ```
Stability: 5 - API Locked
Unless serious bugs are found, this code will not ever
change. Please do not suggest changes in this area; they will be refused. change. Please do not suggest changes in this area; they will be refused.
```
## JSON Output ## JSON Output

24
doc/api_assets/style.css

@ -67,6 +67,30 @@ code a:hover {
margin: 0; margin: 0;
} }
.api_stability_0 {
border-color: #D60027;
}
.api_stability_1 {
border-color: #EC5315;
}
.api_stability_2 {
border-color: #FFD700;
}
.api_stability_3 {
border-color: #AEC516;
}
.api_stability_4 {
border-color: #009431;
}
.api_stability_5 {
border-color: #0084B6;
}
ul.plain { ul.plain {
list-style: none; list-style: none;
} }

10
tools/doc/html.js

@ -69,6 +69,11 @@ function parseLists(input) {
var output = []; var output = [];
output.links = input.links; output.links = input.links;
input.forEach(function(tok) { input.forEach(function(tok) {
if (tok.type === 'code' && tok.text.match(/Stability:.*/g)) {
tok.text = parseAPIHeader(tok.text);
output.push({ type: 'html', text: tok.text });
return;
}
if (state === null) { if (state === null) {
if (tok.type === 'heading') { if (tok.type === 'heading') {
state = 'AFTERHEADING'; state = 'AFTERHEADING';
@ -122,6 +127,11 @@ function parseListItem(text) {
return text; return text;
} }
function parseAPIHeader(text) {
text = text.replace(/(.*:)\s(\d)([\s\S]*)/,
'<pre class="api_stability_$2">$1 $2$3</pre>');
return text;
}
// section is just the first heading // section is just the first heading
function getSection(lexed) { function getSection(lexed) {

Loading…
Cancel
Save