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
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Pick your application stack. Generate a PDF locally or download one from the bro
```bash
dotnet new console -n InvoiceDemo --framework net10.0
cd InvoiceDemo
dotnet add package FullBleed.DotNet --version 0.2.0
dotnet add package FullBleed.DotNet --version 0.2.1
```

Replace `Program.cs` with:
Expand Down Expand Up @@ -236,7 +236,7 @@ Pick your application stack. Generate a PDF locally or download one from the bro

Open `invoice.pdf`. This first example uses standard PDF fonts. Existing .NET 8 and 9 applications can use the same package; see the guide for platform support and explicit fonts.

[C# and .NET quickstart →](getting-started/dotnet.md) · [Components and styles](guides/csharp-components.md) · [LINQ and variable data](https://github.com/fullbleed-engine/fullbleed-dotnet/tree/v0.2.0/samples/FullBleed.DotNet.LinqVdp)
[C# and .NET quickstart →](getting-started/dotnet.md) · [Components and styles](guides/csharp-components.md) · [LINQ and variable data](https://github.com/fullbleed-engine/fullbleed-dotnet/tree/v0.2.1/samples/FullBleed.DotNet.LinqVdp)

<span id="compose-pdfs-with-python-components"></span>

Expand Down
18 changes: 17 additions & 1 deletion tools/verify_dotnet_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@
parser.add_argument('--update-assets', action='store_true')
args = parser.parse_args()
guide = (ROOT / 'docs/getting-started/dotnet.md').read_text(encoding='utf-8')
home = (ROOT / 'docs/index.md').read_text(encoding='utf-8')


def setup_commands(markdown, label):
blocks = re.findall(r'```bash\n(.*?)```', markdown, re.S)
setups = [dedent(block).strip() for block in blocks if 'dotnet new console' in block]
assert len(setups) == 1, f'{label} must have one C# setup block.'
commands = [line.strip() for line in setups[0].splitlines() if line.strip()]
assert len(commands) == 3 and commands[1] == 'cd InvoiceDemo', f'{label} C# setup shape changed.'
return commands


guide_setup = setup_commands(guide, 'Guide')
home_setup = setup_commands(home, 'Homepage')
assert home_setup == guide_setup, 'Homepage C# setup commands differ from the executed guide.'
framework = re.search(r'dotnet new console -n InvoiceDemo --framework (net\d+\.0)', guide).group(1)
framework_version = framework.removeprefix('net')
out = args.out.resolve()
Expand Down Expand Up @@ -53,7 +68,6 @@ def run(label, command, cwd=workspace):
assert f'dotnet add package FullBleed.DotNet --version {version}' in guide
blocks = re.findall(r'```csharp\n(.*?)```', guide, re.S)
assert len(blocks) == 2
home = (ROOT / 'docs/index.md').read_text(encoding='utf-8')
home_code = re.findall(r'```csharp\n(.*?)```', home, re.S)
assert len(home_code) == 1 and dedent(home_code[0]).strip() == blocks[0].strip(), 'Homepage C# example differs from the executed guide.'

Expand Down Expand Up @@ -121,6 +135,8 @@ def run(label, command, cwd=workspace):
'fresh_nuget_http_cache': True,
'native_library_override': False,
'homepage_snippet_matches_executed_guide': True,
'homepage_setup_matches_executed_guide': True,
'documented_setup_commands': guide_setup,
'commands': commands,
'outputs': outputs,
'quickstart_pdf_sha256': hashlib.sha256(snippet_pdf.read_bytes()).hexdigest(),
Expand Down
Loading