Skip to content

Commit

Permalink
doc,tools: properly syntax highlight API ref docs
Browse files Browse the repository at this point in the history
Prior to this commit, all <pre> tags were being
highlighted as JavaScript. This has been corrected
to syntax highlight all languages appearing in the
API reference docs. This was accomplished by using
highlight.js instead of SHJS for the frontend lib.

* remove SHJS JavaScript code
* add highlight.js bundle
* fix script tags to reflect replacement
* migrate CSS to use highlight.js classes
* add appropriate documentation
* ensure api_assets README.md stays interal

Fixes: #33363

PR-URL: #33442
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
  • Loading branch information
Derek Lewis authored and codebytere committed Jul 8, 2020
1 parent 383c5b3 commit 6f8b7a8
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 585 deletions.
33 changes: 33 additions & 0 deletions LICENSE
Expand Up @@ -1471,6 +1471,39 @@ The externally maintained libraries used by Node.js are:
THE POSSIBILITY OF SUCH DAMAGE.
"""

- highlight.js, located at doc/api_assets/highlight.pack.js, is licensed as follows:
"""
BSD 3-Clause License

Copyright (c) 2006, Ivan Sagalaev.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

- node-heapdump, located at src/heap_utils.cc, is licensed as follows:
"""
ISC License
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -733,7 +733,7 @@ out/doc/api/assets:

# If it's not a source tarball, we need to copy assets from doc/api_assets
out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
@cp $< $@
@cp $< $@ ; $(RM) out/doc/api/assets/README.md


run-npm-ci = $(PWD)/$(NPM) ci
Expand Down
27 changes: 27 additions & 0 deletions doc/api_assets/README.md
@@ -0,0 +1,27 @@
# API Reference Document Assets

## highlight.pack.js

_Generated by [highlightjs.org/download][] on 2020-05-16._

Grammars included in the custom bundle:

* Bash
* C
* C++
* CoffeeScript
* JavaScript
* JSON
* Markdown
* Plaintext
* Shell Session

## hljs.css

The syntax theme for code snippets in API reference documents.

## style.css

The main stylesheet for API reference documents.

[highlightjs.org/download]: https://highlightjs.org/download/
6 changes: 6 additions & 0 deletions doc/api_assets/highlight.pack.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions doc/api_assets/hljs.css
@@ -0,0 +1,29 @@
.hljs {
font-weight: normal;
font-style: normal;
}

.hljs-symbol {
color: #333;
}

.hljs-keyword {
color: #338;
}

.hljs-string,
.hljs-regexp,
.hljs-number {
color: #E54305;
}

.hljs-doctag {
color: #040404;
}

.hljs-doctag .hljs-type,
.hljs-doctag .hljs-variable,
.hljs-comment {
color: #666;
font-weight: lighter;
}
25 changes: 0 additions & 25 deletions doc/api_assets/sh.css

This file was deleted.

1 change: 0 additions & 1 deletion doc/api_assets/sh_javascript.min.js

This file was deleted.

0 comments on commit 6f8b7a8

Please sign in to comment.