dib-lab / khmer

In-memory nucleotide sequence k-mer counting, filtering, graph traversal and more
http://khmer.readthedocs.io/
Other
749 stars 295 forks source link

reStructuredText markup in `--help` output #981

Open mr-c opened 9 years ago

mr-c commented 9 years ago

This was an early design decision on my part to enable richer formatting in the auto generated scripts documentation.

Since we specify the method or attribute name to sphinx-contrib.autoprogram of the argparse.ArgumentParser to use we can programmatically manipulate it before usage in the script itself.

Bonus: instead of down converting the rST syntax to plain text, use blessings to add bold or italics effects as is useful.

mr-c commented 9 years ago

Example from normalize-by-median.py --help:

With :option:`-s`/:option:`--savetable`, the k-mer counting table
will be saved to the specified file after all sequences have been
processed. With :option:`-d`, the k-mer counting table will be
saved every d files for multifile runs; if :option:`-s` is set,
the specified name will be used, and if not, the name `backup.ct`
will be used.  :option:`-l`/:option:`--loadtable` will load the
specified k-mer counting table before processing the specified
files.  Note that these tables are are in the same format as those
produced by :program:`load-into-counting.py` and consumed by
:program:`abundance-dist.py`.

Specifically:

`:option:`-l`/:option:`--loadtable`

could be rendered as -l,--loadtable and

:program:`load-into-counting.py`

could be rendered as load-into-counting.py and

`backup.ct`

could be rendered using underline (which is not possible to demonstrate in this comment)

All together:

With -s,--savetable, the k-mer counting table will be saved to the specified file after all sequences have been processed. With -d, the k-mer counting table will be saved every d files for multifile runs; if -s is set, the specified name will be used, and if not, the name backup.ct will be used. -l,--loadtable will load the specified k-mer counting table before processing the specified files. Note that these tables are are in the same format as those produced by load-into-counting.py and consumed by abundance-dist.py.

mr-c commented 9 years ago

Note that blessings will turn off terminal effects automatically if connected to a pipe https://pypi.python.org/pypi/blessings#pipe-savvy

ctb commented 9 years ago

s/problematically/programmatically/

mr-c commented 9 years ago

@ctb thx