|
2 | 2 |
|
3 | 3 | [](https://pkg.go.dev/github.com/bwplotka/mdox) [](https://github.com/bwplotka/mdox/releases/latest) [](https://github.com/bwplotka/mdox/actions?query=workflow%3Ago) [](https://goreportcard.com/report/github.com/bwplotka/mdox) |
4 | 4 |
|
5 | | -CLI toolset for maintaining automated, high quality project documentation and website leveraging markdown and git. |
| 5 | +`mdox` (spelled as `md docs`) is a CLI for maintaining automated, high quality project documentation and website leveraging [Github Flavored Markdown](https://github.github.com/gfm/) and git. |
6 | 6 |
|
7 | | -Goal: Allow projects to have self-updating up-to-date documentation available in both markdown (e.g readable from GitHub) and static HTML. Hosted in the same repository as code, fool-proof and integrated with Pull Requests CI and hosting CD. |
| 7 | +## Goals |
8 | 8 |
|
9 | | -### Features |
| 9 | +Allow projects to have self-updating up-to-date documentation available in both markdown (e.g readable from GitHub) and static HTML. Hosted in the same repository as code and integrated with Pull Requests CI, hosting CD and code generation. |
10 | 10 |
|
11 | | -```bash mdox-gen-exec="mdox --help" |
12 | | -usage: mdox [<flags>] <command> [<args> ...] |
| 11 | +## Features |
13 | 12 |
|
14 | | -Markdown Project Documentation Toolbox. |
| 13 | +* Enhanced amd consistent formatting for markdown files, focused on `.md` code readability. |
| 14 | +* Auto generation of code block content based on `mdoc-exec` directives (see [#code-generation](#code-generation)). |
| 15 | +* Robust and fast relative and remote link checking. |
| 16 | +* "Localizing" links to relative docs if specified (useful for multi-domain websites or multi-version doc). |
15 | 17 |
|
16 | | -Flags: |
17 | | - -h, --help Show context-sensitive help (also try --help-long and |
18 | | - --help-man). |
19 | | - --version Show application version. |
20 | | - --log.level=info Log filtering level. |
21 | | - --log.format=logfmt Log format to use. Possible options: logfmt or json. |
| 18 | +## Usage |
| 19 | + |
| 20 | +Just run `mdox fmt` and pass markdown files (or glob matching those). |
22 | 21 |
|
23 | | -Commands: |
24 | | - help [<command>...] |
25 | | - Show help. |
| 22 | +For example this README is formatted by the CI on every PR using [`mdox fmt -l *.md` command](https://github.com/bwplotka/mdox/blob/9e183714070f464b1ef089da3df8048aff1abeda/Makefile#L59). |
26 | 23 |
|
27 | | - fmt <files>... |
28 | | - Formats given markdown files uniformly following GFM (Github Flavored |
29 | | - Markdown: https://github.github.com/gfm/). |
| 24 | +```bash mdox-gen-exec="mdox fmt --help" |
| 25 | +usage: mdox fmt [<flags>] <files>... |
30 | 26 |
|
31 | | - Additionally it supports special fenced code directives to autogenerate code |
32 | | - snippets: |
| 27 | +Formats in-place given markdown files uniformly following GFM (Github Flavored |
| 28 | +Markdown: https://github.github.com/gfm/). Example: mdox fmt *.md |
33 | 29 |
|
34 | | - ```<lang> mdox-gen-exec="<executable + arguments>" |
| 30 | +Flags: |
| 31 | + -h, --help Show context-sensitive help (also try |
| 32 | + --help-long and --help-man). |
| 33 | + --version Show application version. |
| 34 | + --log.level=info Log filtering level. |
| 35 | + --log.format=logfmt Log format to use. Possible options: logfmt or |
| 36 | + json. |
| 37 | + --check If true, fmt will not modify the given files, |
| 38 | + instead it will fail if files needs formatting |
| 39 | + --code.disable-directives If false, fmt will parse custom fenced code |
| 40 | + directives prefixed with 'mdox-gen' to |
| 41 | + autogenerate code snippets. For example: |
| 42 | + |
| 43 | + ```<lang> mdox-gen-exec="<executable + arguments>" |
| 44 | + |
| 45 | + This directive runs executable with arguments |
| 46 | + and put its stderr and stdout output inside |
| 47 | + code block content, replacing existing one. |
| 48 | + --links.anchor-dir=LINKS.ANCHOR-DIR |
| 49 | + Anchor directory for link transformers. PWD |
| 50 | + flag is not specified. |
| 51 | + --links.localise.address-regex=LINKS.LOCALISE.ADDRESS-REGEX |
| 52 | + If specified, all HTTP(s) links that target a |
| 53 | + domain and path matching given regexp will be |
| 54 | + transformed to relative to anchor dir path (if |
| 55 | + exists).Absolute path links will be converted |
| 56 | + to relative links to anchor dri as well. |
| 57 | + -l, --links.validate If true, all links will be validated |
| 58 | + --links.validate.address-regex=^$ |
| 59 | + If specified, all links will be validated, |
| 60 | + except those matching the given target address. |
| 61 | +
|
| 62 | +Args: |
| 63 | + <files> Markdown file(s) to process. |
35 | 64 |
|
36 | | - This directive runs executable with arguments and put its stderr and stdout |
37 | | - output inside code block content, replacing existing one. |
| 65 | +``` |
38 | 66 |
|
39 | | - Example: mdox fmt *.md |
| 67 | +### Code Generation |
40 | 68 |
|
41 | | - web gen <files>... |
42 | | - Generate versioned docs |
| 69 | +It's not uncommon that documentation is explaining code or configuration snippets. One of the challenges of such documentation is keeping it up to date. This is where `mdox` code block directives comes handy! To ensure mdox will auto update code snippet add `mdox-gen-exec="<whatever command you want take output from>"` after language directive on code block. |
43 | 70 |
|
| 71 | +For example this Readme contains `mdox --help` which is has to be auto generated on every PR: |
44 | 72 |
|
| 73 | +```markdown |
| 74 | +``` bash mdox-gen-exec="mdox fmt --help" |
| 75 | +... |
45 | 76 | ``` |
46 | 77 |
|
47 | | -### Production Usage |
| 78 | +You can disable this feature by specifying `--code.disable-directives` |
48 | 79 |
|
49 | | -* [Thanos](https://github.com/bwplotka/thanos) (TBD) |
| 80 | +### Installing |
50 | 81 |
|
51 | | -## Requirements |
| 82 | +Requirements to build this tool: |
52 | 83 |
|
53 | | -* Go 1.14+ |
| 84 | +* Go 1.15+ |
54 | 85 | * Linux or MacOS |
55 | 86 |
|
56 | | -## Installing |
57 | | - |
58 | 87 | ```shell |
59 | 88 | go get github.com/bwplotka/mdox && go mod tidy |
60 | 89 | ``` |
61 | 90 |
|
62 | | -or via [bingo](github.com/bwplotka/bingo) if want to pin it: |
| 91 | +or via [bingo](https://github.com/bwplotka/bingo) if want to pin it: |
63 | 92 |
|
64 | 93 | ```shell |
65 | 94 | bingo get -u github.com/bwplotka/mdox |
66 | 95 | ``` |
67 | 96 |
|
68 | | -Any contributions are welcome! Just use GitHub Issues and Pull Requests as usual. We follow [Thanos Go coding style](https://thanos.io/contributing/coding-style-guide.md/) guide. |
| 97 | +### Production Usage |
| 98 | +
|
| 99 | +* [Thanos](https://github.com/bwplotka/thanos) (TBD) |
| 100 | +
|
| 101 | +## Contributing |
| 102 | +
|
| 103 | +Any contributions are welcome! Just use GitHub Issues and Pull Requests as usual. We follow [Thanos Go coding style](https://thanos.io/tip/contributing/coding-style-guide.md/) guide. |
69 | 104 |
|
70 | 105 | ## Initial Author |
71 | 106 |
|
|
0 commit comments