Skip to content

Commit 3f8027e

Browse files
committed
remove redundant self-reference in documentation
The link is relevant in the API.md, but superfluous in the generated HTML documentation. Hence, it's removed where the HTML documentation is generated.
1 parent e6bbb52 commit 3f8027e

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

packages/clients/afm/API.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This is a default compilation of POLAR feature packages for online services. This document and its child documents describe the setup.
44

5+
For all additional details, check the [full documentation](https://dataport.github.io/polar/docs/afm/client-afm.html).
6+
57
## Requirements
68

79
To understand this document, programming knowledge (preferably in JavaScript) are required. This is a technical document describing how to integrate the map client with its programmatic API.

packages/clients/snowbox/API.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
This is an API file that is used as part of the generated documentation. It will appear as main document in the snowbox's documentation.
44

55
If the snowbox implemented any own features that are not derived from either core of plugins, this would be the place to document them. However, since that's not the case, it only features this introduction text and the link list below.
6+
7+
For all additional details, check the [full documentation](https://dataport.github.io/polar/docs/snowbox/client-snowbox.html).

scripts/makeDocs.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@ function toHtml(filePath, children) {
8484
</html>`
8585
}
8686

87+
/**
88+
* Removes documentation page link from documentation page; it's only relevant
89+
* when reading the API.md directly, not on this page.
90+
* @param {string} html the html'd API.md
91+
* @returns {string} html without the link to itself
92+
*/
93+
const filter = (html) => {
94+
const filterRegex =
95+
/<p>For all additional details, check the <a href=".*">full documentation<\/a>.<\/p>/g
96+
97+
const matches = (html.match(filterRegex) || []).length
98+
99+
if (matches !== 1) {
100+
console.error(html)
101+
102+
throw new Error(
103+
`makeDocs.js expected to remove a self-reference in HTML generated from an API.md with exactly one match, but found ${matches} matches. This indicates an unexpected change in the API.md.`
104+
)
105+
}
106+
107+
return html.replace(filterRegex, '')
108+
}
109+
87110
const getDistinguishingFileNameFromPath = (path) => path.split('/').slice(-1)[0]
88111

89112
const dependencyPaths = fs
@@ -99,13 +122,15 @@ fs.readdirSync(docPath).forEach((f) => fs.rmSync(`${docPath}/${f}`))
99122
;[clientPath, ...dependencyPaths].forEach((path) => {
100123
const isMain = path === clientPath
101124
const markdownFile = `${path}/${isMain ? 'API.md' : 'README.md'}`
102-
const html = toHtml(
103-
markdownFile,
104-
isMain
105-
? dependencyPaths.map(
106-
(path) => getDistinguishingFileNameFromPath(path) + '.html'
107-
)
108-
: null
125+
const html = (isMain ? filter : (x) => x)(
126+
toHtml(
127+
markdownFile,
128+
isMain
129+
? dependencyPaths.map(
130+
(path) => getDistinguishingFileNameFromPath(path) + '.html'
131+
)
132+
: null
133+
)
109134
)
110135
const targetName = `${
111136
path === clientPath ? 'client-' : ''

0 commit comments

Comments
 (0)