Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update supported admonition types #124

Merged
merged 2 commits into from
Jan 5, 2025
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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docs-builder.
# docs-builder.

You've reached the home of the latest incarnation of the documentation tooling.
You've reached the home of the latest incarnation of the documentation tooling.

This repository is host to:

Expand Down Expand Up @@ -48,7 +48,7 @@ docker run -v "./.git:/app/.git" -v "./docs:/app/docs" -v "./.artifacts:/app/.ar

This ensures `.git`/`docs` and `.artifacts` (the default output directory) are mounted.

The tool will default to incremental compilation.
The tool will default to incremental compilation.
Only the changed files on subsequent runs will be compiled unless you pass `--force`
to force a new compilation.

Expand All @@ -66,15 +66,15 @@ docker run -v "./.git:/app/.git" -v "./docs:/app/docs" -v "./.artifacts:/app/.ar
-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
Each page is compiled on demand as you browse http://localhost:8080 and is never cached so changes to files and
navigation will always be reflected upon refresh.

Note the docker image is `linux-x86` and will be somewhat slower to invoke on OSX due to virtualization.


## Github Action

The `docs-builder` tool is available as github action.
The `docs-builder` tool is available as github action.

Since it runs from a precompiled distroless image `~25mb` it's able to execute snappy. (no need to wait for building the tool itself)

Expand All @@ -93,8 +93,8 @@ jobs:

### GitHub Pages

To setup the tool to publish to GitHub pages use the following configuration.
**NOTE**: In the near feature we'll make this a dedicated single step Github ction
To setup the tool to publish to GitHub pages use the following configuration.
**NOTE**: In the near feature we'll make this a dedicated single step Github ction

```yaml
steps:
Expand All @@ -112,10 +112,10 @@ steps:
uses: actions/[email protected]
with:
path: .artifacts/docs/html

- name: Deploy artifact
id: deployment
uses: actions/[email protected]
uses: actions/[email protected]
```

Note `prefix:` is required to inject the appropiate `--path-prefix` argument to `docs-builder`
Expand All @@ -135,7 +135,7 @@ If you have dotnet 8 installed you can use its CLI to publish a self-contained `
binary. (On my M2 Pro mac the binary is currently 13mb)

```bash
$ dotnet publish "src/docs-builder/docs-builder.csproj" -c Release -o .artifacts/publish \
dotnet publish "src/docs-builder/docs-builder.csproj" -c Release -o .artifacts/publish \
--self-contained true /p:PublishTrimmed=true /p:PublishSingleFile=false /p:PublishAot=true -a arm64
```

Expand All @@ -147,5 +147,5 @@ 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
For refence here's the `markitpy-doc` docset (50k markdown files) currently takes `14s` vs `several minutes` compared to
existing surveyed tools
29 changes: 12 additions & 17 deletions docs/source/syntax/admonitions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
---

Check warning on line 1 in docs/source/syntax/admonitions.md

View workflow job for this annotation

GitHub Actions / docs

Directive block 'important' is unsupported. See https://github.com/elastic/docs-builder/issues/3 for more information.
title: Admonitions
---

Admonitions allow you to highlight important information with varying levels of priority. In software documentation, these blocks are used to emphasize risks, provide helpful advice, or share relevant but non-critical details.

```{attention}
Asciidoc and V3 currently support different admonition types. See [#106](https://github.com/elastic/docs-builder/issues/106) for details.
```

## Basic admonitions

Admonitions can span multiple lines and support inline formatting.
Expand All @@ -19,9 +15,9 @@
### Available admonition types

- `note`
- `caution`
- `warning`
- `tip`
- `attention`
- `important`

### Syntax

Expand All @@ -40,18 +36,18 @@
This is a note.
:::

**Caution**
**Warning**

You could permanently lose data or leak sensitive information.

```markdown
:::{caution}
This is a caution.
:::{warning}
This is a warning.
:::
```

```{caution}
This is a caution.
```{warning}
This is a warning.
```

**Tip**
Expand All @@ -68,21 +64,20 @@
This is a tip.
```

**Attention**
**Important**

Ignoring this information could impact performance or the stability of your system.

```markdown
:::{attention}
This is an attention.
:::{important}
This is an important notice.
:::
```

```{attention}
This is an attention.
```{important}
This is an important notice.
```


````

````{tab-item} Asciidoc Syntax
Expand Down
2 changes: 1 addition & 1 deletion docs/source/syntax/conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
title: Conditionals
---

```{caution}
```{warning}
This feature is not currently supported in Elastic Docs V3.
```
2 changes: 1 addition & 1 deletion docs/source/syntax/example_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
title: Example blocks
---

```{caution}
```{warning}
This feature is not currently supported in Elastic Docs V3.
```
2 changes: 1 addition & 1 deletion docs/source/syntax/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Images can be referenced from the top-level `_static` dir or a local image dir.

## Screenshots

```{caution}
```{warning}
This feature is not currently supported in Elastic Docs V3.
```

Expand Down
2 changes: 1 addition & 1 deletion docs/source/syntax/passthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
title: Passthrough blocks
---

```{caution}
```{warning}
This feature is not currently supported in Elastic Docs V3.
```
2 changes: 1 addition & 1 deletion docs/source/syntax/sidebars.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
title: Sidebars
---

```{caution}
```{warning}
This feature is not currently supported in Elastic Docs V3.
```
2 changes: 1 addition & 1 deletion docs/source/syntax/tagged_regions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
title: Tagged regions
---

```{caution}
```{warning}
This feature is not currently supported in Elastic Docs V3. See [File inclusion](./file_inclusion.md) for an alternative.
```
6 changes: 3 additions & 3 deletions src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public DirectiveBlockParser()

private Dictionary<string, string> _admonitionData = new();

private readonly string[] _admonitions = [ "attention", "caution", "note", "tip" ];
private readonly string[] _admonitions = [ "important", "warning", "note", "tip" ];

private readonly string[] _versionBlocks = [ "versionadded", "versionchanged", "versionremoved", "deprecated" ];

Expand All @@ -56,12 +56,12 @@ public DirectiveBlockParser()
{ "margin", 4 },
{ "sidebar", 4 },
{ "code-cell", 8 },

{ "admonition", 3 },
{ "attention", 3 },
{ "caution", 3 },
{ "danger", 3 },
{ "error", 3 },
{ "hint", 3 },
{ "important", 3 },
{ "seealso", 3 }
}.ToFrozenDictionary();

Expand Down
11 changes: 5 additions & 6 deletions tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ A regular paragraph.
public void SetsCorrectAdmonitionType() => Block!.Admonition.Should().Be(directive);
}

public class CautionTests(ITestOutputHelper output) : AdmonitionTests(output, "caution")
public class WarningTests(ITestOutputHelper output) : AdmonitionTests(output, "warning")
{
[Fact]
public void SetsTitle() => Block!.Title.Should().Be("Caution");
public void SetsTitle() => Block!.Title.Should().Be("Warning");
}

public class NoteTests(ITestOutputHelper output) : AdmonitionTests(output, "note")
Expand All @@ -41,10 +41,10 @@ public class TipTests(ITestOutputHelper output) : AdmonitionTests(output, "tip")
public void SetsTitle() => Block!.Title.Should().Be("Tip");
}

public class AttentionTests(ITestOutputHelper output) : AdmonitionTests(output, "attention")
public class ImportantTests(ITestOutputHelper output) : AdmonitionTests(output, "important")
{
[Fact]
public void SetsTitle() => Block!.Title.Should().Be("Attention");
[Fact]
public void SetsTitle() => Block!.Title.Should().Be("Important");
}

public class NoteTitleTests(ITestOutputHelper output) : DirectiveTest<AdmonitionBlock>(output,
Expand Down Expand Up @@ -82,4 +82,3 @@ A regular paragraph.
[Fact]
public void SetsDropdownOpen() => Block!.DropdownOpen.Should().BeTrue();
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ A regular paragraph.
public class DangerTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "danger");
public class ErrorTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "error");
public class HintTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "hint");
public class ImportantTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "important");
public class AttentionTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "attention");
public class CautionTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "caution");
public class SeeAlsoTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "seealso");
public class AdmonitionTitleTests(ITestOutputHelper output) : AdmonitionUnsupportedTests(output, "admonition");
// ReSharper restore UnusedType.Global
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace Elastic.Markdown.Tests.Inline;
public abstract class DirectiveBlockLinkTests(ITestOutputHelper output, [LanguageInjection("markdown")] string content)
: InlineTest<LinkInline>(output,
$$"""
```{caution}
```{warning}
:name: caution_ref
This is a 'caution' admonition
This is a 'warning' admonition
```

{{content}}
Expand All @@ -31,9 +31,9 @@ protected override void AddToFileSystem(MockFileSystem fileSystem)
title: Special Requirements
---

```{attention}
```{important}
:name: hint_ref
This is a 'caution' admonition
This is a 'important' admonition
```
""";
fileSystem.AddFile(@"docs/source/testing/req.md", inclusion);
Expand Down
Loading