Skip to content

Commit da6817b

Browse files
erlliamstrager
authored andcommitted
Website: generate CLI documentation with EJS
Only generate a man page from tools/generate-cli-docs
1 parent 19cf27d commit da6817b

File tree

5 files changed

+304
-563
lines changed

5 files changed

+304
-563
lines changed

tools/generate-cli-docs

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,8 @@ def main():
2525
"docs/cli.adoc",
2626
]
2727
)
28-
subprocess.check_output(
29-
[
30-
"asciidoctor",
31-
"-b",
32-
"html5",
33-
"-D",
34-
"website/public/",
35-
"-o",
36-
"cli/index.html",
37-
"docs/cli.adoc",
38-
]
39-
)
4028

4129
process_man()
42-
process_html()
4330

4431

4532
def process_man():
@@ -79,85 +66,6 @@ def process_man():
7966
file_path.write_text(contents)
8067

8168

82-
def process_html():
83-
file_path = pathlib.Path("website/public/cli/index.html")
84-
contents = file_path.read_text()
85-
86-
top = """<!-- Copyright (C) 2020 Matthew Glazar -->
87-
<!-- See end of file for extended copyright information. -->
88-
<!-- This file was generated using generate-cli-docs. -->
89-
"""
90-
bottom = """
91-
92-
<!--
93-
quick-lint-js finds bugs in JavaScript programs.
94-
Copyright (C) 2020 Matthew Glazar
95-
96-
This file is part of quick-lint-js.
97-
98-
quick-lint-js is free software: you can redistribute it and/or modify
99-
it under the terms of the GNU General Public License as published by
100-
the Free Software Foundation, either version 3 of the License, or
101-
(at your option) any later version.
102-
103-
quick-lint-js is distributed in the hope that it will be useful,
104-
but WITHOUT ANY WARRANTY; without even the implied warranty of
105-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106-
GNU General Public License for more details.
107-
108-
You should have received a copy of the GNU General Public License
109-
along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>.
110-
-->
111-
"""
112-
head = """<head>
113-
<title>quick-lint-js: CLI documentation</title>
114-
<meta charset="utf-8" />
115-
<link href="../main.css" rel="stylesheet" />
116-
</head>"""
117-
header = """<header>
118-
<h1><a href="..">quick-lint-js</a></h1>
119-
<nav>
120-
<ul>
121-
<li class="side-bar-only"><a href="..">Home</a></li>
122-
<li><a href="../install/">Install</a></li>
123-
<li><a href="../demo/">Try online</a></li>
124-
<li><a href="../errors/">Error docs</a></li>
125-
<li class="current-page">CLI docs</li>
126-
<li><a href="../benchmarks/">Benchmarks</a></li>
127-
<li>
128-
<a href="https://github.com/quick-lint/quick-lint-js"
129-
>Code on GitHub</a
130-
>
131-
</li>
132-
</ul>
133-
</nav>
134-
</header>
135-
<p>This page documents the quick-lint-js command-line interface (CLI).</p>"""
136-
footer = """<footer>
137-
<nav>
138-
<ul>
139-
<li><a href="..">quick-lint-js home page</a></li>
140-
<li><a href="../hiring/">we're hiring! get paid to code</a></li>
141-
<li><a href="../benchmarks/">benchmarks vs other linters</a></li>
142-
<li><a href="../demo/">try quick-lint-js in your browser</a></li>
143-
<li>
144-
<a href="https://github.com/quick-lint/quick-lint-js">source code on GitHub</a>
145-
</li>
146-
<li><a href="../license/">copyright and license information</a></li>
147-
</ul>
148-
</nav>
149-
</footer>"""
150-
151-
l = len("<!DOCTYPE html>")
152-
contents = contents[: l + 1] + top + contents[l + 1 :] + bottom
153-
contents = re.sub(r"(?s)<head>(.*?)</head>", head, contents)
154-
contents = re.sub(r"(?s)<h1>(.*?)</h1>", header, contents)
155-
contents = re.sub(r'(?s)<div id="footer">(.*?)</div>\n</div>', footer, contents)
156-
contents = contents.replace('<body class="article">', '<body class="article side-bar-nav">')
157-
158-
file_path.write_text(contents)
159-
160-
16169
if __name__ == "__main__":
16270
main()
16371

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"node": ">=14.14.0"
1010
},
1111
"dependencies": {
12+
"asciidoctor": "^2.2.4",
1213
"ejs": "^3.1.6",
1314
"express": "^4.17.1",
1415
"mime": "^2.5.2",

website/public/cli/index.ejs.html

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!DOCTYPE html>
2+
<!-- Copyright (C) 2020 Matthew Glazar -->
3+
<!-- See end of file for extended copyright information. -->
4+
<html>
5+
<head>
6+
<script>
7+
//<%
8+
let fs = await import("fs");
9+
let asciidoctor = (await import("asciidoctor")).default();
10+
11+
let adoc = await fs.promises.readFile("../../../docs/cli.adoc", "utf-8");
12+
let cliDocumentation = asciidoctor.convert(adoc);
13+
//%>
14+
</script>
15+
<title>quick-lint-js: CLI documentation</title>
16+
<meta charset="utf-8" />
17+
<link href="../main.css" rel="stylesheet" />
18+
</head>
19+
20+
<body class="side-bar-nav">
21+
<header>
22+
<h1><a href="../">quick-lint-js</a></h1>
23+
<p class="tag-line">quick-lint-js finds bugs in JavaScript programs.</p>
24+
<nav>
25+
<ul>
26+
<li class="side-bar-only"><a href="..">Home</a></li>
27+
<li><a href="../install/">Install</a></li>
28+
<li><a href="../demo/">Try online</a></li>
29+
<li><a href="../errors/">Error docs</a></li>
30+
<li class="current-page">CLI docs</li>
31+
<li><a href="../benchmarks/">Benchmarks</a></li>
32+
<li>
33+
<a href="https://github.com/quick-lint/quick-lint-js"
34+
>Code on GitHub</a
35+
>
36+
</li>
37+
</ul>
38+
</nav>
39+
</header>
40+
41+
<main>
42+
<p>This page documents the quick-lint-js command-line interface (CLI).</p>
43+
<%- cliDocumentation; %>
44+
</main>
45+
46+
<footer>
47+
<nav>
48+
<ul>
49+
<li><a href="..">quick-lint-js home page</a></li>
50+
<li><a href="../hiring/">we're hiring! get paid to code</a></li>
51+
<li><a href="../benchmarks/">benchmarks vs other linters</a></li>
52+
<li><a href="../demo/">try quick-lint-js in your browser</a></li>
53+
<li>
54+
<a href="https://github.com/quick-lint/quick-lint-js"
55+
>source code on GitHub</a
56+
>
57+
</li>
58+
<li><a href="../license/">copyright and license information</a></li>
59+
</ul>
60+
</nav>
61+
</footer>
62+
</body>
63+
</html>
64+
65+
<!--
66+
quick-lint-js finds bugs in JavaScript programs.
67+
Copyright (C) 2020 Matthew Glazar
68+
69+
This file is part of quick-lint-js.
70+
71+
quick-lint-js is free software: you can redistribute it and/or modify
72+
it under the terms of the GNU General Public License as published by
73+
the Free Software Foundation, either version 3 of the License, or
74+
(at your option) any later version.
75+
76+
quick-lint-js is distributed in the hope that it will be useful,
77+
but WITHOUT ANY WARRANTY; without even the implied warranty of
78+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79+
GNU General Public License for more details.
80+
81+
You should have received a copy of the GNU General Public License
82+
along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>.
83+
-->

0 commit comments

Comments
 (0)