Dev guide
This commit is contained in:
@@ -6,7 +6,7 @@ async function run(ctx, argv) {
|
||||
function usage() {
|
||||
ctx.console.error(
|
||||
'usage: man [-k keyword] [-f name] [-l] [[section] name]\n' +
|
||||
' Section 1: /bin utilities; section 7: Bare OS handbook (man 7 bare-os-handbook).\n' +
|
||||
' Section 1: /bin; section 7: handbook + developer guide (man handbook, man devguide).\n' +
|
||||
' Data: /share/man/man.json on the system drive.'
|
||||
)
|
||||
ctx.exitCode = 2
|
||||
@@ -92,10 +92,48 @@ async function run(ctx, argv) {
|
||||
}
|
||||
|
||||
if (mode === 'list') {
|
||||
const rows = db.pages
|
||||
.map((p) => ({ n: p.name, s: p.section }))
|
||||
.sort((a, b) => (a.n !== b.n ? (a.n < b.n ? -1 : 1) : a.s - b.s))
|
||||
for (const r of rows) ctx.console.log(r.n + '(' + r.s + ')')
|
||||
const CAT_ORDER = ['coreutils', 'extra', 'handbook', 'devguide']
|
||||
const CAT_HEADING = {
|
||||
coreutils: 'Section 1 — /bin utilities',
|
||||
extra: 'Section 1 — Git and shell',
|
||||
handbook: 'Section 7 — Handbook',
|
||||
devguide: 'Section 7 — Developer guide'
|
||||
}
|
||||
function listCategoryOf(p) {
|
||||
const c = p.listCategory
|
||||
if (c === 'coreutils' || c === 'extra' || c === 'handbook' || c === 'devguide')
|
||||
return c
|
||||
if (p.section === 7) {
|
||||
const n = p.name
|
||||
if (n.startsWith('devguide-') || n === 'bare-os-developer-guide') return 'devguide'
|
||||
return 'handbook'
|
||||
}
|
||||
if (p.name === 'git' || p.name === 'bare-os-shell') return 'extra'
|
||||
return 'coreutils'
|
||||
}
|
||||
const rows = db.pages.map((p) => ({
|
||||
n: p.name,
|
||||
s: p.section,
|
||||
cat: listCategoryOf(p)
|
||||
}))
|
||||
rows.sort((a, b) => {
|
||||
const ia = CAT_ORDER.indexOf(a.cat)
|
||||
const ib = CAT_ORDER.indexOf(b.cat)
|
||||
const ca = ia === -1 ? 99 : ia
|
||||
const cb = ib === -1 ? 99 : ib
|
||||
if (ca !== cb) return ca - cb
|
||||
if (a.n !== b.n) return a.n < b.n ? -1 : 1
|
||||
return a.s - b.s
|
||||
})
|
||||
let prevCat = ''
|
||||
for (const r of rows) {
|
||||
if (r.cat !== prevCat) {
|
||||
if (prevCat !== '') ctx.console.log('')
|
||||
ctx.console.log(CAT_HEADING[r.cat] || r.cat)
|
||||
prevCat = r.cat
|
||||
}
|
||||
ctx.console.log(' ' + r.n + '(' + r.s + ')')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user