Skip to content

Commit 5eede85

Browse files
katrinafyimre
andauthored
Fetch readme and generate Markdown for CLI flags at build time (#113)
* use custom integration * add message * rm cli.md * trying single code block highlight again. why is it blue??? * steal starlight's colours to make it grey ;-; * Revert "steal starlight's colours to make it grey ;-;" This reverts commit 2b85c81. * Revert "trying single code block highlight again. why is it blue???" This reverts commit 35353c7. * biome * remove escapeMarkdown * remove default value formatting * try add remark-smartypants to package.json * Revert "remove default value formatting" This reverts commit 0936b31. * format markdown as rich text, rather than code. i think, that this is generally nicer to read. However, this means that the website text is rendered from the same text as the CLI --help. The website understands Markdown, but the CLI does not (obviously) so we have to be careful. I would suggest that when writing help, the focus should be on readability within the *console*. This means that while Markdown can be used, it should be limited to syntax which is unobtrusive in raw text. Raw text is still the main format which the help text will be rendered in. Personally, these would be okay: - single `*` or `_` for emphasis (with preference for `*`) - single backticks for inline code - four space indentation for code blocks - bullet and numbered lists Imo, these would *not* be okay, because they appear too jarring in plain text: - code blocks with triple backtick fences. this includes any astro-specific asides and the like. - link syntax with `[link](https://url)` - bold when used for subheadings like `**Note**:` I think this is a good compromise which lets the same text be usable for both CLI --help and the website's rich text HTML. * pnpm lock * reorder sidebar based on (subjective) frequency of use. also tweak page titles to be in Title Case. * extract lychee-version.ts and add note of current version to docs * Apply suggestions from code review Co-authored-by: Matthias Endler <[email protected]> * undo 3 blank lines --------- Co-authored-by: Matthias Endler <[email protected]>
1 parent b8e15e9 commit 5eede85

File tree

10 files changed

+204
-606
lines changed

10 files changed

+204
-606
lines changed

astro.config.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import starlight from "@astrojs/starlight";
22
import { defineConfig } from "astro/config";
3+
import smartypants from "remark-smartypants";
4+
import { generateCliOptionsIntegration } from "./src/generate-cli-options";
35

46
// https://astro.build/config
57
export default defineConfig({
68
site: "https://lychee.cli.rs",
9+
markdown: {
10+
remarkPlugins: [
11+
// automatically converting smart dashes causes problems with cli arguments.
12+
// to insert dashes, use unicode or &mdash; or &ndash;.
13+
[smartypants, { dashes: false }],
14+
],
15+
},
716
integrations: [
17+
generateCliOptionsIntegration("src/content/docs/guides/_cli.md"),
818
starlight({
919
expressiveCode: {
1020
themes: ["catppuccin-frappe", "catppuccin-latte"],
@@ -38,11 +48,11 @@ export default defineConfig({
3848
label: "Guides",
3949
items: [
4050
"guides/getting-started",
41-
"guides/library",
42-
"guides/config",
4351
"guides/cli",
52+
"guides/config",
4453
"guides/output",
4554
"guides/preprocessing",
55+
"guides/library",
4656
],
4757
},
4858
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@astrojs/check": "^0.9.5",
2121
"@astrojs/starlight": "^0.36.2",
2222
"astro": "^5.15.3",
23+
"remark-smartypants": "^3.0.2",
2324
"sharp": "^0.34.4",
2425
"typescript": "^5.9.3"
2526
},

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/docs/guides/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/cli.md

src/content/docs/guides/_cli.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Command-Line Flags
3+
---
4+
<!--
5+
The _cli.md file is used as a template to generate the cli.md file
6+
at build time.
7+
-->
8+
9+
README-OPTIONS-PLACEHOLDER
10+
11+
## Repeating Options
12+
13+
Some options can be specified multiple times. This is true for:
14+
15+
- `--exclude`
16+
- `--exclude-path`
17+
- `--header`
18+
- `--include`
19+
- `--remap`
20+
- `--scheme`
21+
22+
Here is an example:
23+
24+
```bash
25+
lychee --exclude https://example.com --exclude https://example.org README.md
26+
```
27+
28+
To specify multiple values in this way, the argument flag should be repeated.
29+
Otherwise, the extra values would be treated as link checking inputs.
30+

0 commit comments

Comments
 (0)