{ "info": { "author": "Rebecca Turner", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Topic :: Text Processing :: Markup" ], "description": "argdown\n#######\n\nArgdown is an extension to Python\u2019s argparse_ module that adds Markdown and RST\ndocumentation export.\n\nThe argparse module is great at generating command-line usage and help texts,\nbut pasting pre-formatted and indented terminal output into a ``readme.md`` is\nquite ugly. argdown is a python module that provides a function\n``argdown.md_help(parser)`` that accepts an ``ArgumentParser`` object and\nreturns a string of lovely help text.\n\nArgdown requires a fully formed ArgumentParser object, after all the\n``add_argument()`` s have been executed. The only way to make sure the\nArgumentParser object is created in the same way that it would be during normal\nscript execution is to execute the script until the arguments are parsed. To do\nthis, argdown reads the input file(s) until it reads a line containing\n``.parse_args(``. The rest of the file, being irrelevant to the command-line\ninvocation, is truncated, and a call to ``argdown.md_help()`` is inserted to\ngenerate the Markdown from the parser. It is important to note that this means\nthe whole script up until the call to ``parse_args`` is executed in its\nentirety, including any side-effects that may entail \u2014 argdown does not\nattempt to sanitize the code in any way.\n\nThere are two ways to use argdown \u2014 from the command-line, as detailed in the\nArguments and Usage section, and for more persistent behavior, from a similar\n``.argdown`` file, as detailed in the ``.argdown`` section.\n\n``.argdown``\n############\n\nA ``.argdown`` file is a python literal and may be a list of preference-dicts\nor a single preference-dict.\n\nHere\u2019s an example ``.argdown`` preference-dict with all possible values /\noptions filled in \u2014 any keys ommitted will default to these values (except for\n``options``, which defaults to the empty set \u2014 all options are shown here for\nreference purposes). If ``use-stdin`` is present in the ``options`` key, the\ncontents of the ``files`` key are discarded. No keys are mandatory, and an\n``.argdown`` consisting of an empty dict corresponds to the behavior of running\n``argdown`` from the command-line, with the exception of the command-line\ninvocation not executing all ``.py`` files in the current directory.\n\n::\n\n {\n 'files': ['*.py'],\n 'options': {\n 'use-stdin', 'spacey', 'rst', 'hide-default', 'truncate-help'\n },\n 'header': 'Arguments and Usage',\n 'usage-header': 'Usage',\n 'ref-header': 'Quick reference table',\n 'args-header': 'Arguments',\n 'hierarchy': '#=-*+.',\n 'header-depth': 1\n 'encoding': 'utf-8',\n 'function': None\n }\n\nAny command-line arguments (see below) will override their corresponding values\nin all of a ``.argdown``\u2019s preference-dicts.\n\nNote that the ``.argdown`` will be parsed as Python code using\n|ast.literal_eval|_, so feel free to use comments, raw strings, or other\nPython niceties. Function calls won\u2019t be executed, however.\n\nArguments and Usage\n###################\nUsage\n=====\n\n::\n\n usage: argdown [-h] [-] [--license] [--header HEADER]\n [--usage-header USAGE_HEADER] [--ref-header REF_HEADER]\n [--args-header ARGS_HEADER] [-s] [-r] [-e HIERARCHY] [-d] [-t]\n [--header-depth HEADER_DEPTH] [--encoding ENCODING]\n [-f FUNCTION] [-v]\n [src_file [src_file ...]]\n\n\nArguments\n=========\nQuick reference table\n---------------------\n+------+-------------------+-------------------------+---------------------------+\n|Short |Long |Default |Description |\n+------+-------------------+-------------------------+---------------------------+\n|``-h``|``--help`` | |Show help |\n+------+-------------------+-------------------------+---------------------------+\n|``-`` | | |Read from STDIN |\n+------+-------------------+-------------------------+---------------------------+\n| |``--license`` | |Print license |\n+------+-------------------+-------------------------+---------------------------+\n| |``--header`` |``Arguments and Usage`` |Header text |\n+------+-------------------+-------------------------+---------------------------+\n| |``--usage-header`` |``Usage`` |Header text |\n+------+-------------------+-------------------------+---------------------------+\n| |``--ref-header`` |``Quick reference table``|Header text |\n+------+-------------------+-------------------------+---------------------------+\n| |``--args-header`` |``Arguments`` |Header text |\n+------+-------------------+-------------------------+---------------------------+\n|``-s``|``--spacey`` | |Blank lines after headers |\n+------+-------------------+-------------------------+---------------------------+\n|``-r``|``--rst`` | |Generate rst |\n+------+-------------------+-------------------------+---------------------------+\n|``-e``|``--hierarchy`` |``#=-*+.`` |rst header order |\n+------+-------------------+-------------------------+---------------------------+\n|``-d``|``--hide-default`` | |Hide default arg values |\n+------+-------------------+-------------------------+---------------------------+\n|``-t``|``--truncate-help``| |Truncate help in this table|\n+------+-------------------+-------------------------+---------------------------+\n| |``--header-depth`` |``1`` |Header depth of top header |\n+------+-------------------+-------------------------+---------------------------+\n| |``--encoding`` |``utf-8`` |Input file encoding |\n+------+-------------------+-------------------------+---------------------------+\n|``-f``|``--function`` |``None`` |Function to call in file |\n+------+-------------------+-------------------------+---------------------------+\n|``-v``|``--version`` | |Show version |\n+------+-------------------+-------------------------+---------------------------+\n\n``-h``, ``--help``\n------------------\nshow this help message and exit\n\n``-``\n-----\nRead from STDIN instead of a file.\n\n``--license``\n-------------\nPrint license information (MIT) and exit.\n\n``--header`` (Default: Arguments and Usage)\n-------------------------------------------\nHeader text for the `Arguments and Usage` section.\n\n``--usage-header`` (Default: Usage)\n-----------------------------------\nHeader text for the `Usage` section.\n\n``--ref-header`` (Default: Quick reference table)\n-------------------------------------------------\nHeader text for the `Quick reference table` section, a simple table of all the\narguments.\n\n``--args-header`` (Default: Arguments)\n--------------------------------------\nHeader text for the `Arguments` section, a detailed listing of all the\narguments.\n\n``-s``, ``--spacey``\n--------------------\nOutput a blank line after headers.\n\n``-r``, ``--rst``\n-----------------\nGenerate rst (reStructured Text) instead of Markdown.\n\n``-e``, ``--hierarchy`` (Default: ``#=-*+.``)\n---------------------------------------------\nOrder of header characters to use for rst output.\n\n``-d``, ``--hide-default``\n--------------------------\nDon't output default values for the arguments.\n\n``-t``, ``--truncate-help``\n---------------------------\nTruncate help in the `Quick reference table` section so that the table's width\ndoesn't exceed `--width`. Makes terminal output prettier but means you'll\nprobably have to re-write help messages.\n\n``--header-depth`` (Default: 1)\n-------------------------------\nHeader depth; number of hashes to output before the top-level header.\n\n``--encoding`` (Default: utf-8)\n-------------------------------\nEncoding of all input files. Frankly, there's no excuse to ever use this\nargument\n\n``-f``, ``--function`` (Default: None)\n--------------------------------------\nFunction to be called to parse args. For example, if the arg-parsing mechanism\nis contained in a `console()` function (common if the script is a module and\nhas a console entry point defined), enter `--function console` if `console()`\nmust be called to define the argument parser.\n\n``-v``, ``--version``\n---------------------\nshow program's version number and exit\n\n\nToy test usage\n##############\n\nIf a file ``test.py`` reads ::\n\n import argparse\n import argdown\n\n parser = argparse.ArgumentParser(description='Process some integers.')\n\n parser.add_argument('integers', metavar='N', type=int, nargs='+',\n help='an integer for the accumulator')\n parser.add_argument('--sum', dest='accumulate', action='store_const',\n const=sum, default=max,\n help='sum the integers (default: find the max)')\n\n args = parser.parse_args()\n\n\nThen running ::\n\n argdown test.py\n\n\nWill output ::\n\n # Arguments and Usage\n ## Usage\n ```\n usage: argdown [-h] [--sum] N [N ...]\n ```\n\n ## Arguments\n ### Quick reference table\n |Short|Long |Default |Description\n |-----|--------|-----------------------|----------------------------------------\n |`-h` |`--help`| |show this help message and exit\n | |`--sum` ||sum the integers (default: find the max)\n\n ### `-h`, `--help`\n show this help message and exit\n\n ### `--sum` (Default: )\n sum the integers (default: find the max)\n\nShort Descriptions\n##################\n\n1. check for .short_descriptions file\n2. check for passed filename\n\n::\n\n if 'argdown' in globals():\n short_descriptions = {\n '--help': 'Show help',\n '-': 'Read from STDIN',\n '--license': 'Print license',\n '--header': 'Header text',\n '--usage-header': 'Header text',\n '--ref-header': 'Header text',\n '--args-header': 'Header text',\n '--spacey': 'Blank lines after headers',\n '--rst': 'Generate rst',\n '--hierarchy': 'rst header order',\n '--hide-default': 'Hide default arg values',\n '--truncate-help': 'Truncate help in this table',\n '--header-depth': 'Header depth of top header',\n '--encoding': 'Input file encoding',\n '--function': 'Function to call in file',\n '--version': 'Show version',\n }\n\n\nKnown bugs\n##########\n\nThere are no known bugs.\n\nUnknown bugs\n############\n\nProbably a lot. This script was built to handle the subset of ``argparse``\u2019s\nfeatures that I use, so I imagine there are areas in which ``argdown`` performs\npoorly. Please open an issue if you find something.\n\nMissing features\n################\n\nThe quick reference table output isn\u2019t great; see above where the ``Default``\ncolumn is included despite containing no content.\n\nCurrently, without ``truncate_help=False`` passed to ``argdown.md_help``, the\ndescription field at the end of the table is truncated to the width of the\nterminal to prevent the table from looking awful. I\u2019d like to add a feature to\npass a dict of short descriptions to improve that in the future.\n\nLicense\n#######\n\nMIT, see ``license.txt``\n\n.. |argparse| replace:: ``argparse``\n.. _argparse: https://docs.python.org/3/library/argparse.html\n.. _license.txt: blob/master/license.txt\n.. |ast.literal_eval| replace:: ``ast.literal_eval``\n.. _ast.literal_eval: https://docs.python.org/3/library/ast.html#ast.literal_eval\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/9999years/argdown", "keywords": "markdown argparse", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "argdown", "package_url": "https://pypi.org/project/argdown/", "platform": "", "project_url": "https://pypi.org/project/argdown/", "project_urls": { "Homepage": "https://github.com/9999years/argdown" }, "release_url": "https://pypi.org/project/argdown/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Markdown export for the argparse module", "version": "0.0.1" }, "last_serial": 3057320, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "6a054a9f985ba36bf98916e46175d34d", "sha256": "05e78848e54c21139284db8bb163ca880ddb68213c30b7b334a29311a0dfabf7" }, "downloads": -1, "filename": "argdown-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6a054a9f985ba36bf98916e46175d34d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14297, "upload_time": "2017-07-29T05:26:01", "url": "https://files.pythonhosted.org/packages/25/70/7cd6cbd527d5d7bdfebce7ab0c514a2bdabffb24991cb910475929de2f76/argdown-0.0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6a054a9f985ba36bf98916e46175d34d", "sha256": "05e78848e54c21139284db8bb163ca880ddb68213c30b7b334a29311a0dfabf7" }, "downloads": -1, "filename": "argdown-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6a054a9f985ba36bf98916e46175d34d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14297, "upload_time": "2017-07-29T05:26:01", "url": "https://files.pythonhosted.org/packages/25/70/7cd6cbd527d5d7bdfebce7ab0c514a2bdabffb24991cb910475929de2f76/argdown-0.0.1-py3-none-any.whl" } ] }