Skip to content

Commit 45b5636

Browse files
committed
"Enforce strict mode in docs builder and refine title handling"
Added the `--strict` flag to the docs builder for stricter validation. Refactored title handling logic to delay fallback to filename when no title is found. Minor fixes in generated link text in docs for better clarity.
1 parent 4e47efc commit 45b5636

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
# we run our artifact directly please use the prebuild
3737
# elastic/docs-builder@main GitHub Action for all other repositories!
3838
- name: Build documentation
39-
run: .artifacts/publish/docs-builder/release/docs-builder
39+
run: .artifacts/publish/docs-builder/release/docs-builder --strict

docs/source/syntax/titles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ As well as when using the autolink naming feature e.g:
2323
[titles.md]()
2424
```
2525

26-
Generated link text: [](syntax/titles.md)
26+
Generated link text: [](titles.md)
2727

2828

2929

src/Elastic.Markdown/IO/MarkdownFile.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ private void ReadDocumentInstructions(MarkdownDocument document)
100100
.FirstOrDefault(block => block is HeadingBlock { Level: 1 })?
101101
.GetData("header") as string;
102102

103-
if (string.IsNullOrEmpty(Title))
104-
{
105-
Title = RelativePath;
106-
Collector.EmitWarning(FilePath, "Document has no title, using file name as title.");
107-
}
108-
109103
if (document.FirstOrDefault() is YamlFrontMatterBlock yaml)
110104
{
111105
var raw = string.Join(Environment.NewLine, yaml.Lines.Lines);
@@ -114,7 +108,13 @@ private void ReadDocumentInstructions(MarkdownDocument document)
114108
// TODO remove when migration tool and our demo content sets are updated
115109
var deprecatedTitle = YamlFrontMatter.Title;
116110
if (!string.IsNullOrEmpty(deprecatedTitle))
111+
{
117112
Collector.EmitWarning(FilePath, "'title' is no longer supported in yaml frontmatter please use a level 1 header instead.");
113+
// TODO remove fallback once migration is over and we fully deprecate front matter titles
114+
if (string.IsNullOrEmpty(Title))
115+
Title = deprecatedTitle;
116+
}
117+
118118

119119
// set title on yaml front matter manually.
120120
// frontmatter gets passed around as page information throughout
@@ -143,6 +143,13 @@ private void ReadDocumentInstructions(MarkdownDocument document)
143143
else
144144
YamlFrontMatter = new YamlFrontMatter { Title = Title };
145145

146+
if (string.IsNullOrEmpty(Title))
147+
{
148+
Title = RelativePath;
149+
Collector.EmitWarning(FilePath, "Document has no title, using file name as title.");
150+
}
151+
152+
146153

147154
var contents = document
148155
.Where(block => block is HeadingBlock { Level: >= 2 })

0 commit comments

Comments
 (0)