From 192192a09e2d2e0d6bdd0934f602d2dbbf10ed06 Mon Sep 17 00:00:00 2001 From: Luke Arduini Date: Thu, 27 Dec 2012 20:32:53 -0500 Subject: [PATCH] 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. --- doc/api/documentation.markdown | 34 ++++++++++++++++++++++++---------- doc/api_assets/style.css | 24 ++++++++++++++++++++++++ tools/doc/html.js | 10 ++++++++++ 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/doc/api/documentation.markdown b/doc/api/documentation.markdown index 70a76c2487..ffb9cff9c8 100644 --- a/doc/api/documentation.markdown +++ b/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 and in the process of being redesigned. -The notices look like this: - - Stability: 1 Experimental - 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 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. 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 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. +``` -* **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. +``` -* **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. +``` ## JSON Output diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index 5523984ce1..de3f07c58c 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -67,6 +67,30 @@ code a:hover { 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 { list-style: none; } diff --git a/tools/doc/html.js b/tools/doc/html.js index 63c7c14074..087f726a35 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -69,6 +69,11 @@ function parseLists(input) { var output = []; output.links = input.links; 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 (tok.type === 'heading') { state = 'AFTERHEADING'; @@ -122,6 +127,11 @@ function parseListItem(text) { return text; } +function parseAPIHeader(text) { + text = text.replace(/(.*:)\s(\d)([\s\S]*)/, + '
$1 $2$3
'); + return text; +} // section is just the first heading function getSection(lexed) {