Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions actions/publish-single-page-docs/src/selftest.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ try {
const css = readFileSync(join(stage, 'my-service', 'assets', 'doc.css'), 'utf8');
assert.match(css, /--color-kb-500: #af144b;/);
assert.match(css, /\.kb-doc\b/);
// The knowledge base's Preflight strips list markers; the doc must restore them.
assert.match(css, /\.kb-doc ul \{ list-style-type: disc; \}/);
assert.match(css, /\.kb-doc ol \{ list-style-type: decimal; \}/);
});

check('packs a tarball with kb-docs.json at the root', () => {
Expand Down
7 changes: 7 additions & 0 deletions actions/publish-single-page-docs/src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ body { margin: 0; font-family: var(--font-sans); color: var(--text-body); }
/* ── Flow ─────────────────────────────────────────────────────────────────── */
.kb-doc p { margin: 0 0 1.25rem; }
.kb-doc ul, .kb-doc ol { margin: 0 0 1.25rem; padding-left: 1.5rem; }
/* Markers are declared, not inherited from the browser default: inside the
knowledge base Tailwind's Preflight sets list-style: none on every list. */
.kb-doc ul { list-style-type: disc; }
.kb-doc ul ul { list-style-type: circle; }
.kb-doc ul ul ul { list-style-type: square; }
.kb-doc ol { list-style-type: decimal; }
.kb-doc li { margin: 0.375rem 0; }
.kb-doc li::marker { color: var(--text-muted); }
.kb-doc li > ul, .kb-doc li > ol { margin: 0.375rem 0; }
.kb-doc hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.kb-doc img, .kb-doc video { max-width: 100%; height: auto; border-radius: var(--radius-md); }
Expand Down
39 changes: 36 additions & 3 deletions scripts/setup-test-apps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const PLATFORM_OVERVIEW_BODY = `<h1 id="platform-overview" tabindex="-1">Platfor
<pre class="mermaid">flowchart LR
client --&gt; gateway --&gt; service</pre>`;

/** Body of doc 2 — a second doc in the same bundle, proving expansion. */
/** Body of doc 2 — a second doc in the same bundle, proving expansion; nested lists and a task list for the marker fallback. */
const RELEASE_PROCESS_BODY = `<h1 id="release-process" tabindex="-1">Release Process <a class="kb-anchor" href="#release-process">#</a></h1>
<p>Releases are cut from <code>master</code> on demand.</p>
<blockquote>
Expand All @@ -105,7 +105,39 @@ const RELEASE_PROCESS_BODY = `<h1 id="release-process" tabindex="-1">Release Pro
<li>Tag the commit.</li>
<li>Publish the GitHub Release.</li>
<li>The publish-single-page-docs action attaches <code>kb-docs.tar.gz</code>.</li>
</ol>`;
</ol>
<h2 id="checklist" tabindex="-1">Checklist <a class="kb-anchor" href="#checklist">#</a></h2>
<ul>
<li>Changelog updated
<ul>
<li>Breaking changes called out
<ul>
<li>Migration notes linked</li>
</ul>
</li>
</ul>
</li>
<li>Docs bundle attached</li>
</ul>
<h2 id="sign-off" tabindex="-1">Sign-off <a class="kb-anchor" href="#sign-off">#</a></h2>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" checked disabled type="checkbox"> Release notes reviewed</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled type="checkbox"> Announcement sent</li>
</ul>`;

/**
* doc.css as the action published it before it declared list markers: the same
* stylesheet minus that block, task-list rules included. Doc 2 ships it, so its
* computed markers come from the knowledge base's own fallback — the current
* doc.css would win over that fallback and hide whether it works.
*/
const LEGACY_DOC_CSS = DOC_CSS.replace(
/\/\* Markers are declared[\s\S]*?\.kb-doc ol \{ list-style-type: decimal; \}\n/,
'',
).replace(/\.kb-doc li::marker \{[^}]*\}\n/, '');
if (/list-style-type/.test(LEGACY_DOC_CSS) || !/contains-task-list/.test(LEGACY_DOC_CSS)) {
throw new Error('setup-test-apps: could not derive the legacy doc.css from DOC_CSS — update LEGACY_DOC_CSS');
}

/**
* The mermaid bundle the action vendors — the real one, so the suites can
Expand Down Expand Up @@ -155,6 +187,7 @@ const bundleDocs = [
tags: ['process'],
body: RELEASE_PROCESS_BODY,
usesMermaid: false,
legacyCss: true,
},
];

Expand All @@ -173,7 +206,7 @@ function writeSinglePageBundle() {
usesMermaid: doc.usesMermaid,
hasHeading: true,
}));
writeFileSync(join(docDir, CSS_PATH), DOC_CSS);
writeFileSync(join(docDir, CSS_PATH), doc.legacyCss ? LEGACY_DOC_CSS : DOC_CSS);
if (doc.depthFixture) writeFileSync(join(docDir, dirname(CSS_PATH), 'depth-check.css'), DEPTH_CHECK_CSS);
if (doc.usesMermaid) {
copyFileSync(MERMAID_BUNDLE, join(docDir, MERMAID_PATH));
Expand Down
12 changes: 12 additions & 0 deletions src/styles/knowledge-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ a.kb-masthead-link:hover { color: var(--text-heading); }
.kb-single-page { padding: 2rem 1.25rem 3.5rem; }
}

/* List markers for bundles published before the action's doc.css declared
them. Preflight sets list-style: none on every list, and doc.css used to set
only margin and padding, so bullets and numbers vanished. In `base` — after
Preflight, above it on specificity, below `kb-app` — so any marker the doc's
own stylesheet declares (a task list's none, a newer doc.css) still wins. */
@layer base {
.kb-single-page ul { list-style-type: disc; }
.kb-single-page ul ul { list-style-type: circle; }
.kb-single-page ul ul ul { list-style-type: square; }
.kb-single-page ol { list-style-type: decimal; }
Comment thread
oto-macenauer-absa marked this conversation as resolved.
Resolved
}

/* ── Tag pills ───────────────────────────────────────────────────────────── */
.kb-tag {
display: inline-flex;
Expand Down
11 changes: 11 additions & 0 deletions tests/build-integrity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ test.describe('single-page onboarding', () => {
const html = read('platform-overview/index.html');
expect(html).toContain('data-kb-headless="true"');
expect(kbInlineStylesheet(html)).toContain('.kb-single-page');
// Fallback markers for bundles whose doc.css predates its own list rules.
for (const [sel, type] of [
['ul', 'disc'], ['ul ul', 'circle'], ['ul ul ul', 'square'], ['ol', 'decimal'],
]) {
const rule = new RegExp(`\\.kb-single-page ${sel}\\s*\\{\\s*list-style-type:\\s*${type}`);
expect(kbInlineStylesheet(html), `fallback for ${sel}`).toMatch(rule);
}
// The fixture that exercises that fallback really is a pre-marker doc.css.
const legacy = read('release-process/assets/doc.css');
expect(legacy).not.toContain('list-style-type');
expect(legacy).toContain('.contains-task-list');
expect(html.match(/<html\b/gi) ?? []).toHaveLength(1);
expect(html.match(/<head\b/gi) ?? []).toHaveLength(1);
expect(html.match(/<body\b/gi) ?? []).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ body { margin: 0; font-family: var(--font-sans); color: var(--text-body); }
/* ── Flow ─────────────────────────────────────────────────────────────────── */
.kb-doc p { margin: 0 0 1.25rem; }
.kb-doc ul, .kb-doc ol { margin: 0 0 1.25rem; padding-left: 1.5rem; }
/* Markers are declared, not inherited from the browser default: inside the
knowledge base Tailwind's Preflight sets list-style: none on every list. */
.kb-doc ul { list-style-type: disc; }
.kb-doc ul ul { list-style-type: circle; }
.kb-doc ul ul ul { list-style-type: square; }
.kb-doc ol { list-style-type: decimal; }
.kb-doc li { margin: 0.375rem 0; }
.kb-doc li::marker { color: var(--text-muted); }
.kb-doc li > ul, .kb-doc li > ol { margin: 0.375rem 0; }
.kb-doc hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.kb-doc img, .kb-doc video { max-width: 100%; height: auto; border-radius: var(--radius-md); }
Expand Down
18 changes: 18 additions & 0 deletions tests/fixtures/single-page-bundle/release-process/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ <h2 id="steps" tabindex="-1">Steps <a class="kb-anchor" href="#steps">#</a></h2>
<li>Publish the GitHub Release.</li>
<li>The publish-single-page-docs action attaches <code>kb-docs.tar.gz</code>.</li>
</ol>
<h2 id="checklist" tabindex="-1">Checklist <a class="kb-anchor" href="#checklist">#</a></h2>
<ul>
<li>Changelog updated
<ul>
<li>Breaking changes called out
<ul>
<li>Migration notes linked</li>
</ul>
</li>
</ul>
</li>
<li>Docs bundle attached</li>
</ul>
<h2 id="sign-off" tabindex="-1">Sign-off <a class="kb-anchor" href="#sign-off">#</a></h2>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" checked disabled type="checkbox"> Release notes reviewed</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled type="checkbox"> Announcement sent</li>
</ul>
</article>
</body>
</html>
44 changes: 44 additions & 0 deletions tests/web-fragment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,50 @@ test.describe('Single-page docs', () => {
expect(await queryInShadow(page, 'nav#sidebar'), 'single-page doc must not render a sidebar').toBeNull();
expect(await queryInShadow(page, '#kb-masthead'), 'masthead missing').not.toBeNull();
});

// Preflight sets list-style: none on every list, so the markers have to be
// put back, and a task list has to stay marker-free. release-process ships a
// doc.css from before the action declared markers, so its markers come from
// the knowledge base's fallback alone; platform-overview ships the current one.
test('lists keep their bullets and numbers; task lists stay unmarked', async ({ page }) => {
const markers = (path, selectors) => gotoFragment(page, path)
.then(() => waitForFragmentText(page, /./))
.then(() => page.evaluate((sels) => {
function search(root, sel) {
const el = root.querySelector(sel);
if (el) return el;
for (const child of root.querySelectorAll('*')) {
if (child.shadowRoot) {
const found = search(child.shadowRoot, sel);
if (found) return found;
}
}
return null;
}
return Object.fromEntries(sels.map((sel) => {
const el = search(document, sel);
return [sel, el ? getComputedStyle(el).listStyleType : null];
}));
}, selectors));

expect(await markers('/knowledge-base/release-process/', [
'main.kb-single-page ol',
'main.kb-single-page ul',
'main.kb-single-page ul ul',
'main.kb-single-page ul ul ul',
'main.kb-single-page ul.contains-task-list',
])).toEqual({
'main.kb-single-page ol': 'decimal',
'main.kb-single-page ul': 'disc',
'main.kb-single-page ul ul': 'circle',
'main.kb-single-page ul ul ul': 'square',
'main.kb-single-page ul.contains-task-list': 'none',
});

expect(await markers('/knowledge-base/platform-overview/', [
'main.kb-single-page ul.contains-task-list',
])).toEqual({ 'main.kb-single-page ul.contains-task-list': 'none' });
});
});

// ─────────────────────────────────────────────────────────────────────────────
Expand Down
Loading