Skip to content

Commit 4d884f4

Browse files
committed
docs: simplify demos table
1 parent 4c14e87 commit 4d884f4

File tree

3 files changed

+47
-12
lines changed

3 files changed

+47
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,18 +400,17 @@ jobs:
400400
401401
declare -a generators=(
402402
"adoc"
403-
"html"
404403
"xml"
405404
)
406405
407406
# Generate the demos for each variant and generator
408407
for variant in single multi; do
409408
for generator in "${generators[@]}"; do
409+
[[ $generator = xml && $variant = multi ]] && continue
410410
[[ $variant = multi ]] && multipage="true" || multipage="false"
411411
mrdocs --config="$(pwd)/boost/libs/url/doc/mrdocs.yml" "../CMakeLists.txt" --output="$(pwd)/demos/boost-url/$variant/$generator" --multipage=$multipage --generate="$generator"
412412
echo "Number of files in demos/boost-url/$variant/$format: $(find demos/boost-url/$variant/$format -type f | wc -l)"
413413
done
414-
asciidoctor -d book -R "$(pwd)/demos/boost-url/$variant/adoc" -D "$(pwd)/demos/boost-url/$variant/adoc-asciidoc" "$(pwd)/demos/boost-url/$variant/adoc/**/*.adoc"
415414
done
416415
417416
# Compress demos for the artifact

docs/extensions/mrdocs-demos.js

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function getSubdirectoriesSync(url) {
1616
let urlPath = new URL(url).pathname;
1717
let cacheFilenamePath = urlPath.replace(/[^a-zA-Z0-9]/g, '') + '.json';
1818
let cachePath = `${__dirname}/../build/requests/${cacheFilenamePath}`;
19-
fs.mkdirSync(`${__dirname}/../build/requests/`, { recursive: true });
19+
fs.mkdirSync(`${__dirname}/../build/requests/`, {recursive: true});
2020
const readFromCacheFile = fs.existsSync(cachePath) && fs.statSync(cachePath).mtime > new Date(Date.now() - 1000 * 60 * 60 * 24);
2121
const data =
2222
readFromCacheFile ?
@@ -143,20 +143,56 @@ module.exports = function (registry) {
143143
}
144144
}
145145

146-
text += `| ${versionPageTypes.map(pageType => `${versionFormats.length}+| *${humanizePageType(pageType)}*`).join(' ')}\n`;
147-
let formatColumns = versionFormats.map(format => `*${humanizeFormat(format)}*`).join(' | ');
148-
text += `| *Library* | ${formatColumns} | ${formatColumns}\n\n`;
146+
// Remove HTML and Rendered Asciidoc from the list of formats
147+
// - The HTML generator is unmaintained
148+
// - The raw Asciidoc is already rendered by the mrdocs.com server as HTML
149+
versionFormats = versionFormats.filter(format => format !== 'html' && format !== 'adoc-asciidoc');
150+
let multipageFormats = versionFormats.filter(format => format !== 'xml');
151+
152+
let versionFormatColumns = versionFormats.map(format => `*${humanizeFormat(format)}*`).join(' | ');
153+
let multipageFormatColumns = multipageFormats.map(format => `*${humanizeFormat(format)}*`).join(' | ');
154+
155+
// Multicells for the page format taking as many formats as possible for that page type
156+
const toPageTypeCell = pageType => `${(pageType === 'multi' ? multipageFormats : versionFormats).length}+| *${humanizePageType(pageType)}*`;
157+
text += `| ${versionPageTypes.map(toPageTypeCell).join(' ')}\n`;
158+
159+
text += `| *Library* | ${multipageFormatColumns} | ${versionFormatColumns}\n\n`;
149160
for (const library of versionLibraries) {
150161
text += `| ${libraryLink(library)}`
151162
for (const pageType of versionPageTypes) {
152-
for (const format of versionFormats) {
163+
const pageTypeFormats = pageType === 'multi' ? multipageFormats : versionFormats;
164+
for (const format of pageTypeFormats) {
153165
const demoDir = finalDemoDirs.find(
154166
demoDir => demoDir.version === version &&
155-
demoDir.library === library &&
156-
demoDir.pageType === pageType &&
157-
demoDir.format === format);
167+
demoDir.library === library &&
168+
demoDir.pageType === pageType &&
169+
demoDir.format === format);
158170
if (demoDir) {
159-
text += `| ${demoDir.url}[🔗,window=_blank]`
171+
const demoUrlWithSuffix = demoDir.url + (() => {
172+
if (format === 'xml')
173+
{
174+
return '/reference.xml';
175+
}
176+
if (format === 'adoc')
177+
{
178+
if (pageType === 'multi')
179+
{
180+
return '/index.adoc'
181+
}
182+
else {
183+
return '/reference.adoc'
184+
}
185+
}
186+
return '';
187+
})()
188+
if (['adoc', 'xml'].includes(format)) {
189+
const adoc_icon = 'https://avatars.githubusercontent.com/u/3137042?s=200&v=4'
190+
const code_file_icon = 'https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/file-code.svg'
191+
const icon = format === 'adoc' ? adoc_icon : code_file_icon
192+
text += `| image:${icon}[${humanizeLibrary(library)} reference in ${humanizeFormat(format)} format,width=16,height=16,link=${demoUrlWithSuffix},window=_blank]`
193+
} else {
194+
text += `| ${demoUrlWithSuffix}[🔗,window=_blank]`
195+
}
160196
} else {
161197
text += `| `
162198
}

docs/modules/ROOT/pages/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Alan Freitas <[email protected]>
66
:page-tags: mrdocs
77
:navtitle: Home
88

9-
image::MrDocsBanner.jpg[]
9+
image::MrDocsBanner.jpg[link=https://www.mrdocs.com]
1010

1111
- Automating {cpp} reference documentation significantly enhances usability by providing a navigable API and ensuring a single, up-to-date source of truth with minimal effort.
1212
- However, documenting {cpp} poses significant challenges due to discrepancies between the codebase and the public API. Doxygen remains a popular tool, yet it is suboptimal for {cpp} as it fails to fully comprehend {cpp} constructs and requires many transformation steps, including the incorporation of many macros within the {cpp} code. These macros maintain well-formed and ill-formed versions of the code, undermining the goal of unifying the source of truth.

0 commit comments

Comments
 (0)