Skip to content

Commit

Permalink
Merge branch 'feature/auto-man'
Browse files Browse the repository at this point in the history
  • Loading branch information
lucc committed Dec 20, 2024
2 parents 794a0e9 + 5cde150 commit 799083f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 30 deletions.
2 changes: 2 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def update_template_file():
'sphinx.ext.autosectionlabel',
'sphinx.ext.todo',
'sphinx_autodoc_typehints', # https://pypi.org/project/sphinx-autodoc-typehints/
'sphinxarg.ext',
]

autoapi_type = 'python'
Expand Down Expand Up @@ -135,6 +136,7 @@ def update_template_file():
# (source start file, name, description, authors, manual section).
man_pages = [
('man/khard', 'khard', 'Console address book manager', '', 1),
('man/khard-subcommands', 'khard-subcommands', 'Subcommands of khard', '', 1),
('man/khard.conf', 'khard.conf', 'configuration file for khard', '', 5),
]

Expand Down
1 change: 1 addition & 0 deletions doc/source/man.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ The following man pages are available for khard:
:maxdepth: 1

khard(1) <man/khard>
khard-subcommands(1) <man/khard-subcommands>
khard.conf(1) <man/khard.conf>
14 changes: 14 additions & 0 deletions doc/source/man/khard-subcommands.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
khard subcommands
=================

These are all the subcommands and accepted arguments of :manpage:`khard(1)`.

.. argparse::
:module: khard.cli
:func: _sphinxarg_helper
:prog: khard

See also
--------

:manpage:`khard(1)`.
37 changes: 10 additions & 27 deletions doc/source/man/khard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ khard
Synopsis
--------

:program:`khard` [:option:`-c` CONFIG] [:option:`--debug`] [:option:`--skip-unparsable`] SUBCOMMAND ...
.. argparse::
:module: khard.cli
:func: _sphinxarg_helper
:prog: khard
:nosubcommands: true

:program:`khard` :option:`-h` | :option:`--help`

:program:`khard` :option:`-v` | :option:`--version`
-c --config
The default value and the syntax of the config file are explained in
:manpage:`khard.conf(5)`.

Description
-----------
Expand All @@ -18,34 +22,13 @@ modify and delete vCard address book entries. :program:`khard` only works with
store of vCard files. It is intended to be used in conjunction with other
programs like an email client, text editor, vdir synchronizer or VOIP client.

Options
-------

.. option:: -c CONFIG, --config CONFIG

configuration file (default: :file:`~/.config/khard/khard.conf`)

.. option:: --debug

output debugging information

.. option:: -h, --help

show a help message and exit

.. option:: --skip-unparsable

skip unparsable vcards when reading the address books

.. option:: -v, --version

show program's version number and exit

Subcommands
-----------

The functionality of khard is divided into several subcommands. All of these
have their own help text which can be seen with ``khard SUBCOMMAND --help``.
The full list of subcommands and all options can be found in
:manpage:`khard-subcommands(1)`.

Many subcommands accept search terms to limit the number of contacts they
should work on, display or present for selection. The syntax is described in
Expand Down
2 changes: 1 addition & 1 deletion khard/carddav_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __str__(self) -> str:
def get_first(self, property: str, default: str = "") -> str:
"""Get a property from the underlying vCard.
This method should only be called for properties with cardinality *1
This method should only be called for properties with cardinality \\*1
(zero or one). Otherwise only the first value will be returned. If the
property is not present a default will be returned.
Expand Down
5 changes: 5 additions & 0 deletions khard/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,8 @@ def init(argv: list[str]) -> tuple[argparse.Namespace, Config]:
return args, merge_args_into_config(args, conf)
except ConfigError as err:
sys.exit(str(err))


def _sphinxarg_helper():
"""Helper function to return the correct argument parser for the docs."""
return create_parsers()[1]
2 changes: 1 addition & 1 deletion khard/helpers/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def ask(message: str, choices: list[str], default: Optional[str] = None,
None this list must not contain the string "?"
:param default: the answer that should be selected on empty user input
(None means empty input is not accepted)
:parm help: a help text to display to the user if they did not answer
:param help: a help text to display to the user if they did not answer
correctly
:returns: the choice of the user
"""
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ dependencies = [
]

[project.optional-dependencies]
doc = ['sphinx', 'sphinx-autoapi', 'sphinx-autodoc-typehints']
doc = [
'sphinx',
'sphinx-argparse',
'sphinx-autoapi',
'sphinx-autodoc-typehints',
]

[project.urls]
homepage = "https://github.com/lucc/khard"
Expand Down

0 comments on commit 799083f

Please sign in to comment.