Skip to content

Commit 6f8b7a8

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 383c5b3 commit 6f8b7a8

11 files changed

+104
-585
lines changed

LICENSE

+33
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,39 @@ The externally maintained libraries used by Node.js are:
14711471
THE POSSIBILITY OF SUCH DAMAGE.
14721472
"""
14731473

1474+
- highlight.js, located at doc/api_assets/highlight.pack.js, is licensed as follows:
1475+
"""
1476+
BSD 3-Clause License
1477+
1478+
Copyright (c) 2006, Ivan Sagalaev.
1479+
All rights reserved.
1480+
1481+
Redistribution and use in source and binary forms, with or without
1482+
modification, are permitted provided that the following conditions are met:
1483+
1484+
* Redistributions of source code must retain the above copyright notice, this
1485+
list of conditions and the following disclaimer.
1486+
1487+
* Redistributions in binary form must reproduce the above copyright notice,
1488+
this list of conditions and the following disclaimer in the documentation
1489+
and/or other materials provided with the distribution.
1490+
1491+
* Neither the name of the copyright holder nor the names of its
1492+
contributors may be used to endorse or promote products derived from
1493+
this software without specific prior written permission.
1494+
1495+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1496+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1497+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1498+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1499+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1500+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1501+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1502+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1503+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1504+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1505+
"""
1506+
14741507
- node-heapdump, located at src/heap_utils.cc, is licensed as follows:
14751508
"""
14761509
ISC License

Makefile

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

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

738738

739739
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)