Skip to content

Commit

Permalink
Remove need for ‘build’ sub-command
Browse files Browse the repository at this point in the history
  • Loading branch information
irskep committed Aug 29, 2024
1 parent 867b8bb commit 7b3c322
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- run: bun install
# Build the docs
- run: bunx typedoc
- run: bun src/cli.ts build docs
- run: bun src/cli.ts docs
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ typedoc:
bunx typedoc

docs: templates/html/static/client.js
bun src/cli.ts build docs --local
bun src/cli.ts docs --local

gfm:
rm -rf docs/out/gfm
bun src/cli.ts build docs --output-format gfm
bun src/cli.ts docs --output-format gfm

test:
bun test
Expand Down
Binary file modified bun.lockb
Binary file not shown.
29 changes: 29 additions & 0 deletions docs/out/gfm/alternatives.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
DO NOT EDIT THIS FILE DIRECTLY!
It is generated by djockey.
-->
- [Alternatives to Djockey](./alternatives.md#Alternatives-to-Djockey)

<div id="Alternatives-to-Djockey" class="section"
id="Alternatives-to-Djockey">

# Alternatives to Djockey

There are many wonderful documentation systems out there and Djockey
tries to take inspiration from all of them. In the spirit of helping you
solve your real problems, here’s a list of good options with active
maintenance and large communities.

| | Markup | Implementation |
|----|----|----|
| [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) | [CommonMark](https://commonmark.org/) with custom extensions | Python |
| [Sphinx](https://www.sphinx-doc.org/en/master/index.html) | [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html), [MyST](https://mystmd.org) | Python |
| [Docusaurus](https://docusaurus.io) | [CommonMark](https://commonmark.org/), [MDX](https://mdxjs.com), | JavaScript |
| [Starlight](https://starlight.astro.build) | [Markdoc](https://markdoc.dev/docs/syntax), [MDX](https://mdxjs.com), | JavaScript |

</div>


| Previous | Next |
| - | - |
| [Why Djockey? Why Djot?](./why.md) | [The djockey command](./basics/djockey_command.md) |
13 changes: 6 additions & 7 deletions docs/out/gfm/basics/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DO NOT EDIT THIS FILE DIRECTLY!
It is generated by djockey.
-->

- [Deploying](../basics/deploying.md#Deploying)
- [GitHub Pages](../basics/deploying.md#GitHub-Pages)

Expand All @@ -16,7 +17,7 @@
Deploying a Djockey site is the same as any other static site generator.
But for your convenience, here is a GitHub Actions workflow:

``` yaml
```yaml
name: Deploy static content to Pages

on:
Expand Down Expand Up @@ -50,7 +51,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bunx djockey build YOUR_DOCS_FOLDER_HERE
- run: bunx djockey YOUR_DOCS_FOLDER_HERE
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
Expand All @@ -60,14 +61,12 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

```
</div>
</div>

| Previous | Next |
| - | - |
| [Using Markdown](../basics/markdown.md) | [Configuration reference](../basics/configuration.md) |
| Previous | Next |
| --------------------------------------- | ----------------------------------------------------- |
| [Using Markdown](../basics/markdown.md) | [Configuration reference](../basics/configuration.md) |
14 changes: 7 additions & 7 deletions docs/out/gfm/basics/djockey_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
DO NOT EDIT THIS FILE DIRECTLY!
It is generated by djockey.
-->

- [The `djockey`
command](../basics/djockey_command.md#The-djockey-command)

<div id="The-djockey-command" class="section" id="The-djockey-command">

# The `djockey` command

`djockey build <path-to-docs>` will output HTML by default. To output
`djockey <path-to-docs>` will output HTML by default. To output
GitHub Flavored Markdown instead, pass `--output-format=gfm`.

``` text
usage: djockey build [-h] [--local] [-f {html,gfm}] input
```text
usage: djockey [-h] [--local] [-f {html,gfm}] input
positional arguments:
input
Expand All @@ -26,7 +27,6 @@ optional arguments:

</div>


| Previous | Next |
| - | - |
| [Alternatives to Djockey](../alternatives.md) | [Front matter](../basics/frontmatter.md) |
| Previous | Next |
| --------------------------------------------- | ---------------------------------------- |
| [Alternatives to Djockey](../alternatives.md) | [Front matter](../basics/frontmatter.md) |
14 changes: 7 additions & 7 deletions docs/out/gfm/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DO NOT EDIT THIS FILE DIRECTLY!
It is generated by djockey.
-->

- [Getting Started](./getting_started.md#Getting-Started)
- [Building for local viewing vs
deployment](./getting_started.md#Building-for-local-viewing-vs-deployment)
Expand All @@ -13,7 +14,7 @@
Once you’ve [installed Djockey](./installation.md#Installation), create
a file called `djockey.yaml` that looks like this:

``` yaml
```yaml
input_dir: path-to-your-docs
output_dir:
html: docs_out/html
Expand All @@ -40,15 +41,14 @@ site without a web server and some edits to `/etc/hosts`.
To have Djockey use file URLs instead, only valid on your own machine
and not requiring a web server, pass `--local`.

``` sh
djockey build my_docs_dir --local
```sh
djockey my_docs_dir --local
```

</div>

</div>


| Previous | Next |
| - | - |
| [Installation](./installation.md) | [Why Djockey? Why Djot?](./why.md) |
| Previous | Next |
| --------------------------------- | ---------------------------------- |
| [Installation](./installation.md) | [Why Djockey? Why Djot?](./why.md) |
2 changes: 1 addition & 1 deletion docs/src/basics/deploying.dj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bunx djockey build YOUR_DOCS_FOLDER_HERE
- run: bunx djockey YOUR_DOCS_FOLDER_HERE
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
Expand Down
4 changes: 2 additions & 2 deletions docs/src/basics/djockey_command.dj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ order: 0
---
# The `djockey` command

`djockey build <path-to-docs>` will output HTML by default. To output GitHub Flavored Markdown instead, pass `--output-format=gfm`.
`djockey <path-to-docs>` will output HTML by default. To output GitHub Flavored Markdown instead, pass `--output-format=gfm`.

```text
usage: djockey build [-h] [--local] [-f {html,gfm}] input
usage: djockey [-h] [--local] [-f {html,gfm}] input

positional arguments:
input
Expand Down
2 changes: 1 addition & 1 deletion docs/src/getting_started.dj
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ When your site is generated, all internal URLs are prefixed with the value of `u
To have Djockey use file URLs instead, only valid on your own machine and not requiring a web server, pass `--local`.

```sh
djockey build my_docs_dir --local
djockey my_docs_dir --local
```
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
},
"dependencies": {
"@djot/djot": "^0.3.1",
"@poppinss/cliui": "^6.4.1",
"argparse": "^2.0.1",
"fast-glob": "^3.3.2",
"js-yaml": "^4.1.0",
"log-update": "^6.1.0",
"mermaid": "^10.9.1",
"micromatch": "^4.0.8",
"nunjucks": "^3.2.4",
Expand All @@ -43,6 +45,7 @@
"@types/dompurify": "^3.0.5",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/log-update": "^3.1.0",
"@types/micromatch": "^4.0.9",
"@types/node": "^22.4.0",
"@types/nunjucks": "^3.2.6",
Expand Down
26 changes: 8 additions & 18 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,24 @@ import { resolveConfigFromDirectory } from "./config.js";
import { executeConfig } from "./engine/executeConfig.js";
import { ALL_OUTPUT_FORMATS, DjockeyOutputFormat } from "./types.js";

export async function main() {
const args = makeArgumentParser().parse_args();
doBuild(args.input, args.local, args.output_format);
}

export function makeArgumentParser() {
const p = new ArgumentParser();
const subparsers = p.add_subparsers({ required: true });
const buildParser = subparsers.add_parser("build");
buildParser.set_defaults({ action: "build" });
buildParser.add_argument("--local", { default: false, action: "store_true" });
buildParser.add_argument("-f", "--output-format", {
p.add_argument("--local", { default: false, action: "store_true" });
p.add_argument("-f", "--output-format", {
default: [],
choices: ALL_OUTPUT_FORMATS,
action: "append",
});
buildParser.add_argument("input");
p.add_argument("input");

return p;
}

export async function main() {
const args = makeArgumentParser().parse_args();

switch (args.action) {
case "build":
doBuild(args.input, args.local, args.output_format);
break;
default:
throw new Error("Invalid action");
}
}

export async function doBuild(
inputPath: string,
isLocal: boolean,
Expand Down
Loading

0 comments on commit 7b3c322

Please sign in to comment.