adapt-authoring-docs 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/docgen.js +13 -12
- package/bin/docserve.js +1 -1
- package/conf/config.schema.json +8 -23
- package/docsify/docsify.js +39 -10
- package/docsify/js/adapt.js +3 -9
- package/docsify/styles/adapt.css +13 -0
- package/jsdoc3/jsdoc3.js +2 -2
- package/package.json +1 -1
package/bin/docgen.js
CHANGED
|
@@ -17,8 +17,11 @@ process.env.ADAPT_AUTHORING_LOGGER__mute = !DEBUG
|
|
|
17
17
|
const app = App.instance
|
|
18
18
|
let outputdir
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const defaultPages = { // populated in cacheConfigs
|
|
21
|
+
manualCover: undefined,
|
|
22
|
+
manualIndex: undefined,
|
|
23
|
+
sourceIndex: undefined
|
|
24
|
+
}
|
|
22
25
|
/**
|
|
23
26
|
* Caches loaded JSON so we don't load multiple times.
|
|
24
27
|
* Documentation for a module can be enabled in:
|
|
@@ -36,14 +39,12 @@ function cacheConfigs () {
|
|
|
36
39
|
else if (excludes.includes(dep.name)) omitMsg = 'module has been excluded in documentation config'
|
|
37
40
|
if (omitMsg) return console.log(`Omitting ${dep.name}, ${omitMsg}`)
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
sourceIndex = path.join(dep.rootDir, c.sourceIndex).split(path.sep).join(path.posix.sep)
|
|
46
|
-
}
|
|
42
|
+
Object.keys(defaultPages).forEach(p => {
|
|
43
|
+
if (!c[p]) return
|
|
44
|
+
if (defaultPages[p]) return console.log(`${dep.name}: ${p} has been specified by another module as ${defaultPages[p]}`)
|
|
45
|
+
defaultPages[p] = path.join(dep.rootDir, c[p]).split(path.sep).join(path.posix.sep)
|
|
46
|
+
})
|
|
47
|
+
|
|
47
48
|
cache.push({
|
|
48
49
|
...c,
|
|
49
50
|
name: dep.name,
|
|
@@ -90,8 +91,8 @@ async function docs () {
|
|
|
90
91
|
await fs.rm(outputdir, { recursive: true, force: true })
|
|
91
92
|
await fs.mkdir(outputdir)
|
|
92
93
|
await copyRootFiles()
|
|
93
|
-
await jsdoc3(app, cachedConfigs, outputdir,
|
|
94
|
-
await docsify(app, cachedConfigs, outputdir,
|
|
94
|
+
await jsdoc3(app, cachedConfigs, outputdir, defaultPages)
|
|
95
|
+
await docsify(app, cachedConfigs, outputdir, defaultPages)
|
|
95
96
|
await swagger(app, cachedConfigs, outputdir)
|
|
96
97
|
} catch (e) {
|
|
97
98
|
console.log(e)
|
package/bin/docserve.js
CHANGED
|
@@ -36,7 +36,7 @@ App.instance.onReady().then(async app => {
|
|
|
36
36
|
const PORT = 9000
|
|
37
37
|
const OPEN = process.argv.some(a => a === '--open')
|
|
38
38
|
|
|
39
|
-
const server = http.createServer({ root: ROOT,
|
|
39
|
+
const server = http.createServer({ root: ROOT, cache: -1 })
|
|
40
40
|
|
|
41
41
|
server.listen(PORT, () => {
|
|
42
42
|
const url = `http://localhost:${PORT}`
|
package/conf/config.schema.json
CHANGED
|
@@ -12,29 +12,14 @@
|
|
|
12
12
|
"description": "Sections for categorising documentation manual pages",
|
|
13
13
|
"type": "object",
|
|
14
14
|
"default": {
|
|
15
|
-
"getting-started": {
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
"
|
|
22
|
-
"title": "Advanced topics"
|
|
23
|
-
},
|
|
24
|
-
"ui": {
|
|
25
|
-
"title": "Front-end app"
|
|
26
|
-
},
|
|
27
|
-
"other-guides": {
|
|
28
|
-
"title": "Other guides",
|
|
29
|
-
"default": true
|
|
30
|
-
},
|
|
31
|
-
"contributing": {
|
|
32
|
-
"title": "Contributing"
|
|
33
|
-
},
|
|
34
|
-
"reference": {
|
|
35
|
-
"title": "Reference"
|
|
36
|
-
}
|
|
15
|
+
"getting-started": {},
|
|
16
|
+
"concepts": {},
|
|
17
|
+
"development": {},
|
|
18
|
+
"documentation": {},
|
|
19
|
+
"contributing": {},
|
|
20
|
+
"reference": {},
|
|
21
|
+
"other-guides": { "default": true }
|
|
37
22
|
}
|
|
38
23
|
}
|
|
39
24
|
}
|
|
40
|
-
}
|
|
25
|
+
}
|
package/docsify/docsify.js
CHANGED
|
@@ -12,10 +12,15 @@ function resolvePath (relativePath) {
|
|
|
12
12
|
return fileURLToPath(new URL(relativePath, import.meta.url))
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
// Capitalise and convert dashes to spaces
|
|
16
|
+
function generateSectionTitle (sectionName) {
|
|
17
|
+
return sectionName[0].toUpperCase() + sectionName.slice(1).replaceAll('-', ' ')
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* Copies all doc files ready for the generator
|
|
17
22
|
*/
|
|
18
|
-
export default async function docsify (app, configs, outputdir,
|
|
23
|
+
export default async function docsify (app, configs, outputdir, defaultPages) {
|
|
19
24
|
const dir = path.resolve(outputdir, 'manual')
|
|
20
25
|
const sectionsConf = app.config.get('adapt-authoring-docs.manualSections')
|
|
21
26
|
const defaultSection = Object.entries(sectionsConf).reduce((m, [id, data]) => data.default ? id : m)
|
|
@@ -52,13 +57,14 @@ export default async function docsify (app, configs, outputdir, manualIndex, sou
|
|
|
52
57
|
})
|
|
53
58
|
}
|
|
54
59
|
[...customFiles, ...globSync('docs/*.md', { cwd: c.rootDir, absolute: true })].forEach(f => {
|
|
55
|
-
if (f === sourceIndex) {
|
|
60
|
+
if (f === defaultPages.sourceIndex) {
|
|
56
61
|
return
|
|
57
62
|
}
|
|
58
63
|
const title = path.basename(f)
|
|
59
|
-
const sectionName = c.manualPages
|
|
64
|
+
const sectionName = c.manualPages?.[title] ?? defaultSection
|
|
60
65
|
|
|
61
66
|
if (!sectionsConf[sectionName]) sectionsConf[sectionName] = {}
|
|
67
|
+
if (!sectionsConf[sectionName].title) sectionsConf[sectionName].title = generateSectionTitle(sectionName)
|
|
62
68
|
if (!sectionsConf[sectionName].pages) sectionsConf[sectionName].pages = []
|
|
63
69
|
|
|
64
70
|
sectionsConf[sectionName].pages.push(title)
|
|
@@ -69,6 +75,19 @@ export default async function docsify (app, configs, outputdir, manualIndex, sou
|
|
|
69
75
|
} catch (e) {}
|
|
70
76
|
})
|
|
71
77
|
}))
|
|
78
|
+
/**
|
|
79
|
+
* Set options
|
|
80
|
+
*/
|
|
81
|
+
const options = {
|
|
82
|
+
name: '<img class="logo" src="assets/logo-outline-colour.png" />Adapt authoring tool<h2>Developer guides</h2>',
|
|
83
|
+
repo: 'https://github.com/adapt-security/adapt-authoring',
|
|
84
|
+
themeColor: '#36cde8',
|
|
85
|
+
loadSidebar: true,
|
|
86
|
+
loadNavbar: false,
|
|
87
|
+
autoHeader: true,
|
|
88
|
+
coverpage: false,
|
|
89
|
+
homepage: false
|
|
90
|
+
}
|
|
72
91
|
/**
|
|
73
92
|
* Copy files
|
|
74
93
|
*/
|
|
@@ -76,20 +95,30 @@ export default async function docsify (app, configs, outputdir, manualIndex, sou
|
|
|
76
95
|
await fs.copy(resolvePath('../assets'), `${dir}/assets`)
|
|
77
96
|
await fs.copy(resolvePath('./js'), `${dir}/js`)
|
|
78
97
|
await fs.copy(resolvePath('./styles'), `${dir}/styles`)
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
|
|
99
|
+
if (defaultPages.manualCover) {
|
|
100
|
+
await fs.copy(defaultPages.manualCover, `${dir}/cover.md`)
|
|
101
|
+
options.coverpage = 'cover.md'
|
|
102
|
+
delete titleMap[path.basename(defaultPages.manualCover)]
|
|
103
|
+
}
|
|
104
|
+
if (defaultPages.manualIndex) {
|
|
105
|
+
await fs.copy(defaultPages.manualIndex, `${dir}/home.md`)
|
|
106
|
+
options.homepage = 'home.md'
|
|
107
|
+
delete titleMap[path.basename(defaultPages.manualIndex)]
|
|
81
108
|
}
|
|
109
|
+
// add Docsify options
|
|
110
|
+
const f = `${dir}/js/adapt.js`
|
|
111
|
+
const s = (await fs.readFile(f)).toString()
|
|
112
|
+
await fs.writeFile(f, s.replace('OPTIONS', JSON.stringify(options)))
|
|
113
|
+
|
|
82
114
|
await Promise.allSettled(Object.entries(titleMap).map(([filename, v]) => fs.copy(v.path, `${dir}/${filename}`)))
|
|
83
115
|
/**
|
|
84
116
|
* Generate custom sidebar
|
|
85
117
|
*/
|
|
86
|
-
let sidebarMd = ''
|
|
118
|
+
let sidebarMd = '<ul class="intro"><li><a href="#/" title="Introduction">Introduction</a></li></ul>'
|
|
87
119
|
Object.entries(sectionsConf)
|
|
88
120
|
.forEach(([id, { title, pages = [] }]) => {
|
|
89
|
-
const filtered = pages.filter(f =>
|
|
90
|
-
const p = titleMap[f].path
|
|
91
|
-
return p !== manualIndex && p !== sourceIndex
|
|
92
|
-
})
|
|
121
|
+
const filtered = pages.filter(f => titleMap[f]?.path)
|
|
93
122
|
if (!filtered || !filtered.length) {
|
|
94
123
|
return
|
|
95
124
|
}
|
package/docsify/js/adapt.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/* global addEventListener localStorage */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
themeColor: '#36cde8',
|
|
7
|
-
loadSidebar: true,
|
|
8
|
-
loadNavbar: false,
|
|
9
|
-
autoHeader: true,
|
|
10
|
-
coverpage: true
|
|
11
|
-
}
|
|
3
|
+
// options dynamically populated in docsify.js
|
|
4
|
+
window.$docsify = OPTIONS
|
|
5
|
+
/* global OPTIONS */
|
|
12
6
|
|
|
13
7
|
function onLoad () {
|
|
14
8
|
updateTheme()
|
package/docsify/styles/adapt.css
CHANGED
|
@@ -27,6 +27,12 @@ h1 > a, h2 > a, h3 > a, h4 > a, h5 > a, h6 > a {
|
|
|
27
27
|
font-weight: 300 !important;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
.big-text {
|
|
31
|
+
font-size: 35px;
|
|
32
|
+
margin: 50px 0;
|
|
33
|
+
text-align: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
summary {
|
|
31
37
|
font-size: 1.15rem;
|
|
32
38
|
cursor: pointer;
|
|
@@ -83,6 +89,13 @@ section.cover .cover-main > p:last-child a:hover,
|
|
|
83
89
|
font-weight: normal;
|
|
84
90
|
font-size: 14px;
|
|
85
91
|
}
|
|
92
|
+
.sidebar ul.intro li {
|
|
93
|
+
margin-left: 0
|
|
94
|
+
}
|
|
95
|
+
.sidebar ul.intro li a {
|
|
96
|
+
font-size: 18px;
|
|
97
|
+
text-decoration: underline;
|
|
98
|
+
}
|
|
86
99
|
.sidebar ul.header {
|
|
87
100
|
padding-top: 20px;
|
|
88
101
|
padding-bottom: 5px;
|
package/jsdoc3/jsdoc3.js
CHANGED
|
@@ -88,10 +88,10 @@ function getSourceIncludes (indexFile) {
|
|
|
88
88
|
return includes
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export default async function jsdoc3 (app, configs, outputdir,
|
|
91
|
+
export default async function jsdoc3 (app, configs, outputdir, defaultPages) {
|
|
92
92
|
cachedConfigs = configs
|
|
93
93
|
const dir = `${outputdir}/backend`
|
|
94
|
-
await writeConfig(app, dir,
|
|
94
|
+
await writeConfig(app, dir, defaultPages.sourceIndex)
|
|
95
95
|
try {
|
|
96
96
|
await execPromise(`npx jsdoc -c ${configPath}`)
|
|
97
97
|
} catch (e) {
|
package/package.json
CHANGED