Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Commands section in wiki documentation #595

Closed
osma opened this issue Jun 23, 2022 · 4 comments · Fixed by #611
Closed

Update Commands section in wiki documentation #595

osma opened this issue Jun 23, 2022 · 4 comments · Fixed by #611
Assignees
Milestone

Comments

@osma
Copy link
Member

osma commented Jun 23, 2022

The Commands page in the wiki is getting really out of date and it is missing commands such as annif index. I think it needs an overhaul. It would be best to try to generate some of the content automatically from the CLI command help.

Thanks to @cbartz for pointing this out.

@juhoinkinen
Copy link
Member

These tools seem like they could be used for the task (maybe they were just mentioned by @cbartz):

@juhoinkinen
Copy link
Member

juhoinkinen commented Aug 8, 2022

I checked how md-click would work.

The current release requires Click version <=7.1.2, and as such does not work with Annif. There is an open PR from a fork, which upgrades the requirement. Using that fork I got this kind of output for each command (each in separate .md file):

list-projects

List available projects.

Usage

Usage: list-projects [OPTIONS]

Options

  • verbosity:

    • Type: STRING
    • Default: error
    • Usage: --verbosity -v

    Either CRITICAL, ERROR, WARNING, INFO or DEBUG

  • projects:

    • Type: <click.types.Path object at 0x7f3326082310>
    • Default: none
    • Usage: -p --projects

    Set path to project configuration file or directory

  • help:

    • Type: BOOL
    • Default: false

CLI Help

Usage: list-projects [OPTIONS]

  List available projects.

Options:
  -v, --verbosity LVL  Either CRITICAL, ERROR, WARNING, INFO or DEBUG
  -p, --projects PATH  Set path to project configuration file or directory
  -v, --verbosity LVL  Either CRITICAL, ERROR, WARNING, INFO or DEBUG
  --help               Show this message and exit.

@juhoinkinen juhoinkinen self-assigned this Aug 8, 2022
@juhoinkinen
Copy link
Member

I hoped mkdocs-click would allow using a custom template for the whole wiki page, but this tool renders the Click commands documentation only to html. Markdown is used only in the template for building the html page. So mkdocs-click is not applicable for this task.

Then I tried sphinx-click plugin for Sphinx with sphinx-markdown-builder. It can use a Sphinx template in .rst format. Output can look like following:

Supported CLI commands in Annif

These are the command line commands of Annif, with REST API equivalents when applicable.
Most of these methods take a projectid parameter. Projects are identified by alphanumeric strings (A-Za-z0-9_-).

annif list-projects

List available projects.

annif list-projects [OPTIONS]

Options

-v(, --verbosity( )

Either CRITICAL, ERROR, WARNING, INFO or DEBUG

-p(, --projects( )

Set path to project configuration file or directory

-v(, --verbosity( )

Either CRITICAL, ERROR, WARNING, INFO or DEBUG

REST equivalent::

GET /projects/

annif show-project

Show information about a project.

annif show-project [OPTIONS] PROJECT_ID

Options

-v(, --verbosity( )

Either CRITICAL, ERROR, WARNING, INFO or DEBUG

-p(, --projects( )

Set path to project configuration file or directory

Arguments

PROJECT_ID()

Required argument

REST equivalent::

GET /projects/<projectid>
The .rst template for above:
===============================
Supported CLI commands in Annif
===============================

These are the command line commands of Annif, with REST API equivalents when applicable.
Most of these methods take a projectid parameter. Projects are identified by alphanumeric strings `(A-Za-z0-9_-)`.

.. click:: annif.cli:run_list_projects
   :prog: annif list-projects

REST equivalent:::

  GET /projects/

.. click:: annif.cli:run_show_project
   :prog: annif show-project

REST equivalent:::

   GET /projects/<projectid>

Unfortunately there are the extra parenthesis following each option and argument, which appear on markdown generation. In normal Sphinx build to html the extra parenthesis are not present.

@juhoinkinen
Copy link
Member

Unfortunately there are the extra parenthesis following each option and argument, which appear on markdown generation. In normal Sphinx build to html the extra parenthesis are not present.

sphinx-markdown-builder has a maintained fork sphinx-notes/markdown-builder and using it the extra parenthesis are not inserted to the the markdown file; I continue with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants