@@ -65,7 +65,7 @@ function createFile(filePath, options, outputDir) {
6565 //const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`
6666 console . log ( `rendering ${ filePath } ` )
6767 const output = jsdoc2md . renderSync ( options )
68- fs . writeFileSync ( path . resolve ( outputDir , `${ fileName } .md` ) , output )
68+ fs . writeFileSync ( path . resolve ( outputDir , `${ fileName } .md` ) , setHeadings ( fileName , output ) )
6969}
7070////([\w-]+)(.js)/
7171function getFileName ( filePath ) {
@@ -128,6 +128,52 @@ function formatDataOrder(dataProvider, orderMenu) {
128128 return tt
129129}
130130
131+ function setHeadings ( sFileNm , sMD ) {
132+
133+ /**
134+ * Adjust MD heading levels to create a clean
135+ * table of contents in GitBook. This method
136+ * replaces the docsify _sidebar.md file.
137+ *
138+ * Notes:
139+ *
140+ * 1. This is a quick-fix for basic compliance with the GitBook framework.
141+ * 2. Expression "~~" renders text as strikethrough for highlighting deprecations.
142+ * 3. Inconsistent use of constants requires a fix.
143+ */
144+
145+ const cHdrLv = "##### " ;
146+ const cWOQL = "WOQL." ;
147+ const cWOQLClient = "woqlClient." ;
148+ const cWOQLLib = "woqlLibrary." ;
149+ const cAccessCtrl = "accessControl." ;
150+
151+ // No action for sidebar (code to create sidebar can be deprecated.)
152+
153+ if ( sFileNm . match ( "sidebar" ) )
154+ return sMD ;
155+
156+ // Simplified pattern for type definitions.
157+
158+ if ( sFileNm . match ( "typedef.js" ) )
159+ return sMD .
160+ replace ( / # # / g, "# " ) .
161+ replace ( / # # # / g, cHdrLv ) ;
162+
163+ // All other patterns.
164+
165+ return sMD .
166+ replace ( / # # / g, "#" ) .
167+ replace ( / # # ~ ~ W O Q L \. / g, `${ cHdrLv } ~~${ cWOQL } ` ) .
168+ replace ( / # # ~ ~ w o q l C l i e n t \. / g, `${ cHdrLv } ~~${ cWOQLClient } ` ) .
169+ replace ( / # # ~ ~ w o q l L i b r a r y \. / g, `${ cHdrLv } ~~${ cWOQLLib } ` ) .
170+ replace ( / # # ~ ~ a c c e s s C o n t r o l \. / g, `${ cHdrLv } ~~${ cAccessCtrl } ` ) .
171+ replace ( / # # W O Q L \. / g, `${ cHdrLv } ${ cWOQL } ` ) .
172+ replace ( / # # w o q l C l i e n t \. / g, `${ cHdrLv } ${ cWOQLClient } ` ) .
173+ replace ( / # # w o q l L i b r a r y \. / g, `${ cHdrLv } ${ cWOQLLib } ` ) .
174+ replace ( / # # a c c e s s C o n t r o l \. / g, `${ cHdrLv } ${ cAccessCtrl } ` ) ;
175+ }
176+
131177/*
132178 {
133179 "id": "WOQLClient",
0 commit comments