mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Ensure --help examples in docs are always up to date, closes #336
Unit tests now check that docs/*.txt help examples are all up-to-date. I ran into a problem here in that the terminal_width needed to be more accurately defined - so I replaced update-docs-help.sh with update-docs- help.py which hard-codes the terminal width.
This commit is contained in:
parent
3a46d5e3c4
commit
74ad3ff4af
6 changed files with 66 additions and 29 deletions
25
update-docs-help.py
Normal file
25
update-docs-help.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from click.testing import CliRunner
|
||||
from datasette.cli import cli
|
||||
from pathlib import Path
|
||||
|
||||
docs_path = Path(__file__).parent / "docs"
|
||||
|
||||
includes = (
|
||||
("serve", "datasette-serve-help.txt"),
|
||||
("package", "datasette-package-help.txt"),
|
||||
("publish", "datasette-publish-help.txt"),
|
||||
)
|
||||
|
||||
|
||||
def update_help_includes():
|
||||
for name, filename in includes:
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, [name, "--help"], terminal_width=88)
|
||||
actual = "$ datasette {} --help\n\n{}".format(
|
||||
name, result.output
|
||||
)
|
||||
open(docs_path / filename, "w").write(actual)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_help_includes()
|
||||
Loading…
Add table
Add a link
Reference in a new issue