Skip to content

Commit

Permalink
Merge branch 'main' into feature/code-callouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored Dec 19, 2024
2 parents d0a5982 + 42cc222 commit 0e74ea5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Through the `serve` command you can continuously and partially compile your docu

```bash
docker run -v "./.git:/app/.git" -v "./docs:/app/docs" -v "./.artifacts:/app/.artifacts" \
--expose 8080 ghcr.io/elastic/docs-builder:edge serve
-p 8080:8080 ghcr.io/elastic/docs-builder:edge serve
```

Each page is compiled on demand as you browse http://localhost:8080 and is never cached so changes to files and
Expand Down Expand Up @@ -148,4 +148,4 @@ The resulting binary `./.artifacts/publish/docs-builder` will run on machines wi
To test performance it's best to build the binary and run outside of docker:

For refence here's the `markitpy-doc` docset (50k markdown files) currently takes `14s` vs `several minutes` compared to
existing surveyed tools
existing surveyed tools
3 changes: 3 additions & 0 deletions src/Elastic.Markdown/IO/ConfigurationFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon
yaml.Load(textReader);

if (yaml.Documents.Count == 0)
{
context.EmitWarning(sourceFile, "empty configuration");
return;
}

// Examine the stream
var mapping = (YamlMappingNode)yaml.Documents[0].RootNode;
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Markdown/Myst/Directives/AdmonitionBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public string Title
public override void FinalizeAndValidate(ParserContext context)
{
CrossReferenceName = Properties.GetValueOrDefault("name");
DropdownOpen = PropBool("open");
DropdownOpen = TryPropBool("open");
if (DropdownOpen.HasValue)
Classes = "dropdown";
}
Expand Down
10 changes: 10 additions & 0 deletions src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ protected bool PropBool(params string[] keys)
return bool.TryParse(value, out var result) && result;
}

protected bool? TryPropBool(params string[] keys)
{
var value = Prop(keys);
if (string.IsNullOrEmpty(value))
return keys.Any(k => Properties.ContainsKey(k)) ? true : null;

return bool.TryParse(value, out var result) ? result : null;
}


protected string? Prop(params string[] keys)
{
foreach (var key in keys)
Expand Down
1 change: 1 addition & 0 deletions tests/Elastic.Markdown.Tests/OutputDirectoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public async Task CreatesDefaultOutputDirectory()
var logger = new TestLoggerFactory(output);
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ "docs/source/docset.yml", new MockFileData("") },
{ "docs/source/index.md", new MockFileData("test") }
}, new MockFileSystemOptions
{
Expand Down

0 comments on commit 0e74ea5

Please sign in to comment.