Skip to content

Commit

Permalink
Skip self-docs with no content
Browse files Browse the repository at this point in the history
  • Loading branch information
irskep committed Aug 26, 2024
1 parent 08c12f1 commit 3c66cb6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docs/src/basics/markup_demo.djot
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Markup demo

{.tag-aside .warning}
:::
The details of this markup are likely to change, since Djockey is experimental.
:::

## Overriding HTML tags

Djot does not ([yet](https://github.com/jgm/djot/issues/240)) support arbitrary HTML tags in its input or output. Djockey works around this by postprocessing Djot's HTML output. Whenever you add a CSS class starting with `tag-`{.language-plaintext}, Djockey will replace the element's tag with the rest of the class.

{% can't use .dj-djot-demo for features that require the entire Djockey pipeline (yet) %}

Input:

```djot
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.djot
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Djockey is a powerful but experimental static site generator for technical writi
- [x] Literal symbol parsing
- [x] Dark mode
- [ ] Multi-tab code blocks/divs
- [ ] Sections with and without self-docs have the same appearance but only one is clickable
- [x] Sections with and without self-docs have the same appearance but only one is clickable

### Harder stuff

Expand Down
7 changes: 6 additions & 1 deletion src/engine/doctree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type DocTreeSection = {
title: string;
relativePath: string;
selfDoc: DjockeyDoc | null;
selfDocHasContent: boolean;
children: DocTreeSection[];
docs: DjockeyDoc[];
};
Expand All @@ -23,6 +24,7 @@ export function loadDocTree(docs: DjockeyDoc[]): DocTree {
title: "",
relativePath: "",
selfDoc: null,
selfDocHasContent: false,
children: [],
docs: [],
};
Expand All @@ -37,6 +39,7 @@ export function loadDocTree(docs: DjockeyDoc[]): DocTree {
title: path.parse(relativePath).name,
relativePath,
selfDoc: null,
selfDocHasContent: false,
children: [],
docs: [],
};
Expand Down Expand Up @@ -67,6 +70,8 @@ export function loadDocTree(docs: DjockeyDoc[]): DocTree {
if (path.parse(doc.filename).name === "index") {
docSection.selfDoc = doc;
docSection.title = doc.title;

docSection.selfDocHasContent = !!doc.docs.content.children.length;
} else {
docSection.docs.push(doc);
}
Expand Down Expand Up @@ -131,7 +136,7 @@ export function connectNextAndPrevious(
lastDoc = doc;
}

if (section.selfDoc) {
if (section.selfDoc && section.selfDocHasContent) {
processDoc(section.selfDoc);
}

Expand Down
4 changes: 2 additions & 2 deletions src/engine/populateDocTreeDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ function renderSection(

const result = new Array<Block>();

if (level > 1 || section.selfDoc) {
if (level > 1 || section.selfDocHasContent) {
result.push({
tag: "heading",
level,
children: [
section.selfDoc
section.selfDoc && section.selfDocHasContent
? getDocLink(section.selfDoc)
: {
tag: "str",
Expand Down

0 comments on commit 3c66cb6

Please sign in to comment.