Skip to content

Commit 2d678b5

Browse files
authored
Merge pull request #411 from FAIRmat-NFDI/docs-for-cli-api
Add docs for CLI API, tool to report installed readers
2 parents 6bf0bc5 + faa3c07 commit 2d678b5

File tree

7 files changed

+72
-15
lines changed

7 files changed

+72
-15
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ cython_debug/
202202
!dev-requirements.txt
203203
!mkdocs-requirements.txt
204204
!src/pynxtools/nexus-version.txt
205-
docs/how-tos/dataconverter_help_output.md
206205
build/
207206
nexusparser.egg-info/PKG-INFO
208207
.python-version

docs/how-tos/build-a-plugin.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,11 @@ user@box:~$ dataconverter --reader mydatareader --nxdl NXmynxdl --output path_to
155155
Here, the ``--reader`` flag must match the reader name defined in `[project.entry-points."pynxtools.reader"]` in the pyproject.toml file. The NXDL name passed to ``--nxdl``must be a valid NeXus NXDL/XML file in `pynxtools.definitions`.
156156

157157
Aside from this default structure, there are many more flags that can be passed to the
158-
dataconverter call. Here is an output of its ```help``` call:
159-
{!how-tos/dataconverter_help_output.md!}
158+
dataconverter call. Here is its API:
159+
::: mkdocs-click
160+
:module: pynxtools.dataconverter.convert
161+
:command: convert_cli
162+
:prog_name: dataconverter
163+
:depth: 2
164+
:style: table
165+
:list_subcommands: True

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ An introduction to NeXus and its design principles.
5555

5656
### Reference
5757

58+
`pynxtools` has a number of command line tools that can be used to convert data and verify NeXus files. You can more information about the
59+
API [here](reference/cli-api.md).
60+
5861
Within FAIRmat, we maintain a number of reader plugins for different experimental techniques. You can find more information [here](reference/plugins.md).
5962

6063
[Here](reference/definitions.md), you find the detailed list of application definitions and base classes and their respective fields.

docs/reference/cli-api.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# API for command line tools
2+
3+
`pynxtools` supports a number of command line applications. This page provides documentation for their current API.
4+
5+
## Data conversion
6+
Note that simply calling `dataconverter` defaults to `dataconverter convert`.
7+
8+
::: mkdocs-click
9+
:module: pynxtools.dataconverter.convert
10+
:command: main_cli
11+
:prog_name: dataconverter
12+
:depth: 2
13+
:style: table
14+
:list_subcommands: True
15+
16+
## NeXus file verification
17+
<!-- ::: mkdocs-click
18+
:module: "pynxtools.dataconverter.verify
19+
:command: verify_nexus
20+
:prog_name: verify_nexus
21+
:depth: 1
22+
:style: table
23+
:list_subcommands: True -->
24+
25+
::: mkdocs-click
26+
:module: pynxtools.nexus.nexus
27+
:command: main
28+
:prog_name: read_nexus
29+
:depth: 2
30+
:style: table
31+
:list_subcommands: True
32+
33+
## ELN generation
34+
::: mkdocs-click
35+
:module: pynxtools.eln_mapper.eln_mapper
36+
:command: get_eln
37+
:prog_name: generate_eln
38+
:depth: 1
39+
:style: table
40+
:list_subcommands: True

mkdocs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ nav:
2323
- learn/multiple-appdefs.md
2424
- learn/multi-format-reader.md
2525
- Reference:
26+
- reference/cli-api.md
2627
- reference/plugins.md
2728
- reference/definitions.md
2829

@@ -31,9 +32,6 @@ plugins:
3132
- macros:
3233
module_name: src/pynxtools/mkdocs
3334

34-
hooks:
35-
- scripts/generate_dataconverter_help.py
36-
3735
theme:
3836
name: material
3937
palette:

src/pynxtools/dataconverter/convert.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ def format_options(
272272
)
273273

274274

275-
@click.group(cls=CustomClickGroup, default="convert", default_if_no_args=True)
275+
@click.group(
276+
cls=CustomClickGroup,
277+
default="convert",
278+
default_if_no_args=True,
279+
)
276280
def main_cli():
277281
pass
278282

@@ -463,3 +467,10 @@ def write_to_file(text):
463467
ensure_ascii=False,
464468
)
465469
)
470+
471+
472+
@main_cli.command("get-readers")
473+
def get_reader_cli():
474+
"""Prints a list of all installed readers."""
475+
readers = get_names_of_all_readers()
476+
logger.info(f"The following readers are currently installed: {readers}.")

src/pynxtools/nexus/nexus.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,7 @@ def process_nexus_master_file(self, parser):
794794
"--nexus-file",
795795
required=False,
796796
default=None,
797-
help=(
798-
"NeXus file with extension .nxs to learn NeXus different concept"
799-
" documentation and concept."
800-
),
797+
help=("NeXus file with extension .nxs."),
801798
)
802799
@click.option(
803800
"-d",
@@ -806,7 +803,7 @@ def process_nexus_master_file(self, parser):
806803
default=None,
807804
help=(
808805
"Definition path in nexus output (.nxs) file. Returns debug"
809-
"log relavent with that definition path. Example: /entry/data/delays"
806+
" log relevant with that definition path. Example: /entry/data/delays"
810807
),
811808
)
812809
@click.option(
@@ -816,12 +813,15 @@ def process_nexus_master_file(self, parser):
816813
default=None,
817814
help=(
818815
"Concept path from application definition file (.nxdl,xml). Finds out"
819-
"all the available concept definition (IS-A realation) for rendered"
820-
"concept path. Example: /NXarpes/ENTRY/INSTRUMENT/analyser"
816+
" all the available concept definition (IS-A realation) for rendered"
817+
" concept path. Example: /NXarpes/ENTRY/INSTRUMENT/analyser"
821818
),
822819
)
823820
def main(nexus_file, documentation, concept):
824-
"""The main function to call when used as a script."""
821+
"""
822+
Functionality to extract documentation and concept definition
823+
information about the individual parts of a NeXus/HDF5 file."""
824+
825825
logging_format = "%(levelname)s: %(message)s"
826826
stdout_handler = logging.StreamHandler(sys.stdout)
827827
stdout_handler.setLevel(logging.DEBUG)

0 commit comments

Comments
 (0)