Skip to content

Commit af9fb59

Browse files
Derek Lewiscodebytere
Derek Lewis
authored andcommitted
doc,tools: properly syntax highlight API ref docs
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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
1 parent 6b20e84 commit af9fb59

11 files changed

+104
-585
lines changed

LICENSE

+33
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,39 @@ The externally maintained libraries used by Node.js are:
14481448
THE POSSIBILITY OF SUCH DAMAGE.
14491449
"""
14501450

1451+
- highlight.js, located at doc/api_assets/highlight.pack.js, is licensed as follows:
1452+
"""
1453+
BSD 3-Clause License
1454+
1455+
Copyright (c) 2006, Ivan Sagalaev.
1456+
All rights reserved.
1457+
1458+
Redistribution and use in source and binary forms, with or without
1459+
modification, are permitted provided that the following conditions are met:
1460+
1461+
* Redistributions of source code must retain the above copyright notice, this
1462+
list of conditions and the following disclaimer.
1463+
1464+
* Redistributions in binary form must reproduce the above copyright notice,
1465+
this list of conditions and the following disclaimer in the documentation
1466+
and/or other materials provided with the distribution.
1467+
1468+
* Neither the name of the copyright holder nor the names of its
1469+
contributors may be used to endorse or promote products derived from
1470+
this software without specific prior written permission.
1471+
1472+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1473+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1474+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1475+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1476+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1477+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1478+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1479+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1480+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1481+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1482+
"""
1483+
14511484
- node-heapdump, located at src/heap_utils.cc, is licensed as follows:
14521485
"""
14531486
ISC License

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ out/doc/api/assets:
737737

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

742742

743743
run-npm-ci = $(PWD)/$(NPM) ci

doc/api_assets/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# API Reference Document Assets
2+
3+
## highlight.pack.js
4+
5+
_Generated by [highlightjs.org/download][] on 2020-05-16._
6+
7+
Grammars included in the custom bundle:
8+
9+
* Bash
10+
* C
11+
* C++
12+
* CoffeeScript
13+
* JavaScript
14+
* JSON
15+
* Markdown
16+
* Plaintext
17+
* Shell Session
18+
19+
## hljs.css
20+
21+
The syntax theme for code snippets in API reference documents.
22+
23+
## style.css
24+
25+
The main stylesheet for API reference documents.
26+
27+
[highlightjs.org/download]: https://highlightjs.org/download/

doc/api_assets/highlight.pack.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/api_assets/hljs.css

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.hljs {
2+
font-weight: normal;
3+
font-style: normal;
4+
}
5+
6+
.hljs-symbol {
7+
color: #333;
8+
}
9+
10+
.hljs-keyword {
11+
color: #338;
12+
}
13+
14+
.hljs-string,
15+
.hljs-regexp,
16+
.hljs-number {
17+
color: #E54305;
18+
}
19+
20+
.hljs-doctag {
21+
color: #040404;
22+
}
23+
24+
.hljs-doctag .hljs-type,
25+
.hljs-doctag .hljs-variable,
26+
.hljs-comment {
27+
color: #666;
28+
font-weight: lighter;
29+
}

doc/api_assets/sh.css

-25
This file was deleted.

doc/api_assets/sh_javascript.min.js

-1
This file was deleted.

0 commit comments

Comments
 (0)