Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Colorize API stabilitity index headers in docs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
luk- authored and isaacs committed Dec 28, 2012
1 parent e576208 commit 192192a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 10 deletions.
34 changes: 24 additions & 10 deletions doc/api/documentation.markdown
Expand Up @@ -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


Expand Down
24 changes: 24 additions & 0 deletions doc/api_assets/style.css
Expand Up @@ -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;
} }
Expand Down
10 changes: 10 additions & 0 deletions tools/doc/html.js
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 192192a

Please sign in to comment.