Skip to content

Commit 7d01d16

Browse files
committed
docs: simplify docs
1 parent 0b2ac8b commit 7d01d16

File tree

9 files changed

+37
-143
lines changed

9 files changed

+37
-143
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ xcuserdata
7777
*.env
7878

7979
# built docs
80-
public
80+
/public

docs/branding/footer.html.in

-7
This file was deleted.

docs/branding/media/js/script.js

-47
This file was deleted.
File renamed without changes.

docs/branding/media/css/style.css docs/branding/public/media/css/style.css

+1-60
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ body {
77
color: #4a3f2d;
88
}
99

10-
:focus {
10+
:focus:not(:focus-visible) {
1111
outline: 0;
1212
}
1313

@@ -83,22 +83,6 @@ h4 {
8383
display: inline;
8484
}
8585

86-
87-
88-
/* ---- custom classes */
89-
90-
pre.shell,
91-
pre.shell code {
92-
background:#444;
93-
color:#fff;
94-
border-width:0px;
95-
}
96-
pre.shell code::before {
97-
content: '$ ';
98-
display: inline;
99-
}
100-
101-
10286
/* ---- header and sidebar */
10387

10488
#header {
@@ -150,15 +134,6 @@ pre.shell code::before {
150134
z-index:0;
151135
}
152136

153-
#sidebar .vertical_divider {
154-
background-color:#FFFFFF;
155-
bottom:0px;
156-
position:absolute;
157-
top:0px;
158-
right:0px;
159-
width:1px;
160-
}
161-
162137
#sidebar h1 {
163138
font-size:1.2em;
164139
padding:0px;
@@ -187,25 +162,6 @@ pre.shell code::before {
187162
padding:1px 0px 1px 2px;
188163
}
189164

190-
#sidebar li span.verb {
191-
color:#aaa;
192-
padding:2px 3px 0px;
193-
width:30px;
194-
display:block;
195-
float:left;
196-
font-size:9px;
197-
font-family:verdana;
198-
-moz-border-radius:3px;
199-
-webkit-border-radius:3px;
200-
margin-left:0px;
201-
margin-right:5px;
202-
}
203-
204-
#sidebar li.current {
205-
background-repeat: no-repeat;
206-
background-position:right;
207-
}
208-
209165

210166
/* ---- intro */
211167

@@ -219,13 +175,6 @@ pre.shell code::before {
219175
border-radius: 5px;
220176
margin-bottom:40px;
221177
}
222-
.intro pre.base {
223-
background:#444;
224-
color:#29231A;
225-
color:#fff;
226-
border-color:#fff;
227-
font-size:1.5em;
228-
}
229178
.intro h1 {
230179
color: #1C313C;
231180
}
@@ -259,14 +208,6 @@ h1 + h2 {
259208
margin-top: 0px;
260209
}
261210

262-
h2.fixed {
263-
position:fixed;
264-
margin-top: 0;
265-
border-top:none;
266-
right:45px;
267-
top:66px;
268-
}
269-
270211
h2 span {
271212
background: #979592;
272213
float:right;
File renamed without changes.

docs/branding/header.html.in docs/branding/template.html

+5
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ <h1>%(title)s Documentation</h1>
3232
</div>
3333

3434
<div id="content">
35+
%(content)s
36+
</div><!-- end #content -->
37+
38+
</body>
39+
</html>

docs/index.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ API documentation is:
7979
# More information
8080

8181
- License:[MIT](http://opensource.org/licenses/mit-license.php)
82-
- Code: [mcavage/node-ldapjs](https://github.com/mcavage/node-ldapjs)
83-
- node.js version: >=0.8
84-
- Twitter: [@pfmooney](http://twitter.com/pfmooney)
82+
- Code: [ldapjs/node-ldapjs](https://github.com/ldapjs/node-ldapjs)
8583

8684
# What's not in the box?
8785

scripts/build-docs.js

+29-25
Original file line numberDiff line numberDiff line change
@@ -66,56 +66,60 @@ function markdownTOC (markdown) {
6666
}
6767
}
6868

69-
function createHTML (header, footer, text) {
69+
function createHTML (template, text) {
7070
const { attributes, body } = fm(text)
71-
for (const prop in attributes) {
72-
header = header.replace(new RegExp(`%\\(${prop}\\)s`, 'ig'), attributes[prop])
73-
footer = footer.replace(new RegExp(`%\\(${prop}\\)s`, 'ig'), attributes[prop])
74-
}
7571

7672
const { toc, html } = markdownTOC(body)
73+
attributes.toc_html = toc
74+
attributes.content = html
75+
76+
for (const prop in attributes) {
77+
template = template.replace(new RegExp(`%\\(${prop}\\)s`, 'ig'), attributes[prop])
78+
}
7779

78-
header = header.replace(/%\(toc_html\)s/ig, toc)
80+
return template
81+
}
7982

80-
return header + html + footer
83+
async function copyRecursive (src, dest) {
84+
const stats = await fs.stat(src)
85+
const isDirectory = stats.isDirectory()
86+
if (isDirectory) {
87+
await fs.mkdir(dest)
88+
const files = await fs.readdir(src)
89+
for (const file of files) {
90+
await copyRecursive(path.join(src, file), path.join(dest, file))
91+
}
92+
} else {
93+
await fs.copyFile(src, dest)
94+
}
8195
}
8296

8397
async function createDocs () {
8498
const docs = path.resolve(__dirname, '..', 'docs')
8599
const dist = path.resolve(__dirname, '..', 'public')
86100
const branding = path.join(docs, 'branding')
101+
const src = path.join(branding, 'public')
87102

88103
await fs.rmdir(dist, { recursive: true })
89-
await fs.mkdir(dist)
104+
await copyRecursive(src, dist)
105+
106+
const highlightjsStyles = path.resolve(__dirname, '..', 'node_modules', 'highlight.js', 'styles')
107+
await fs.copyFile(path.join(highlightjsStyles, 'default.css'), path.join(dist, 'media', 'css', 'highlight.css'))
90108

91-
const header = await fs.readFile(path.join(branding, 'header.html.in'), { encoding: 'utf8' })
92-
const footer = await fs.readFile(path.join(branding, 'footer.html.in'), { encoding: 'utf8' })
109+
const template = await fs.readFile(path.join(branding, 'template.html'), { encoding: 'utf8' })
93110
const files = await fs.readdir(docs)
94111
for (const file of files) {
95112
if (!file.endsWith('.md')) {
96113
continue
97114
}
98115
const text = await fs.readFile(path.join(docs, file), { encoding: 'utf8' })
99-
const html = createHTML(header, footer, text)
116+
const html = createHTML(template, text)
100117

101118
await fs.writeFile(path.join(dist, file.replace(/md$/, 'html')), html)
102119
}
103-
104-
const dest = path.join(dist, 'media')
105-
const src = path.join(branding, 'media')
106-
const highlightjsStyles = path.resolve(__dirname, '..', 'node_modules', 'highlight.js', 'styles')
107-
await fs.mkdir(dest)
108-
await fs.mkdir(path.join(dest, 'css'))
109-
await fs.mkdir(path.join(dest, 'js'))
110-
await fs.mkdir(path.join(dest, 'img'))
111-
await fs.copyFile(path.join(src, 'css', 'style.css'), path.join(dest, 'css', 'style.css'))
112-
await fs.copyFile(path.join(highlightjsStyles, 'default.css'), path.join(dest, 'css', 'highlight.css'))
113-
await fs.copyFile(path.join(src, 'js', 'script.js'), path.join(dest, 'js', 'script.js'))
114-
await fs.copyFile(path.join(src, 'img', 'logo.svg'), path.join(dest, 'img', 'logo.svg'))
115-
await fs.copyFile(path.join(branding, 'CNAME'), path.join(dist, 'CNAME'))
116120
}
117121

118122
createDocs().catch(ex => {
119123
console.error(ex)
120-
process.exit(1)
124+
process.exitCode = 1
121125
})

0 commit comments

Comments
 (0)