mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-23 13:30:14 -05:00
* refactor some pkg/jmap and groupware methods to make more sense from an API point-of-view * add path parameter documentation, but automate it by injecting their definition into the OpenAPI YAML tree that is extracted from the source code using go-swagger as it is too cumbersome, repetitive and error-prine to document them in the source code; wrote a TypeScript file apidoc-process.ts to do so * add generating an offline HTML file for the OpenAPI documentation using redocly, and injecting a favicon into the resulting HTML; wrote a TypeScript file apidoc-postprocess-html.ts to do so
26 lines
675 B
TypeScript
26 lines
675 B
TypeScript
import * as fs from 'fs'
|
|
import * as cheerio from 'cheerio'
|
|
|
|
const faviconFile = process.argv[2]
|
|
const favicon = fs.readFileSync(faviconFile).toString('base64')
|
|
|
|
let html = ''
|
|
process.stdin.on('data', (chunk) => {
|
|
html += chunk.toString()
|
|
})
|
|
process.stdin.on('end', () => {
|
|
try {
|
|
const $ = cheerio.load(html)
|
|
$('head').append(`<link rel="icon" href="data:image/png;base64,${favicon}">`)
|
|
process.stdout.write($.html())
|
|
process.stdout.write("\n")
|
|
} catch (error) {
|
|
if (error instanceof Error) {
|
|
console.error(`Error occured while post-processing HTML: ${error.message}`)
|
|
} else {
|
|
console.error("Unknown error occurred")
|
|
}
|
|
}
|
|
});
|
|
|