forked from reanahub/reana-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add script to generate cli api docs
closes reanahub/docs.reana.io#22
- Loading branch information
1 parent
e2eb481
commit 44811f7
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,3 +71,7 @@ target/ | |
|
||
# Visual Studio Code files | ||
.vscode/* | ||
|
||
# Docs autogeneration | ||
cmd_list.txt | ||
cli_api.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of REANA. | ||
# Copyright (C) 2020 CERN. | ||
# | ||
# REANA is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
"""REANA client CLI API docs generation.""" | ||
|
||
import click | ||
|
||
from reana_client.cli import cli | ||
|
||
|
||
def _print_code_block(content, lang=''): | ||
print('```{}'.format(lang)) | ||
print(content) | ||
print('```') | ||
|
||
|
||
def generate_cli_docs(): | ||
"""Generate Markdown friendly CLI API documentation.""" | ||
print('# reana-client CLI API\n') | ||
with click.Context(cli) as ctx: | ||
_print_code_block(cli.get_help(ctx), lang='console') | ||
|
||
for cmd_group in cli.cmd_groups: | ||
print('\n## {}'.format(cmd_group.help)) | ||
for cmd_obj in cmd_group.commands.values(): | ||
print('\n### {}\n'.format(cmd_obj.name)) | ||
print(cmd_obj.help) | ||
|
||
|
||
if __name__ == "__main__": | ||
generate_cli_docs() |