{ "info": { "author": "David Hyman, Arm Mbed", "author_email": "support@mbed.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers" ], "description": "# snippet\n[![CircleCI](https://circleci.com/gh/ARMmbed/snippet.svg?style=svg&circle-token=f8151197e9160de7877eda3ae049d0925e9b7ff3)](https://circleci.com/gh/ARMmbed/snippet)\n\nA Python3 tool to extract code snippets from source files\n\nEssentially, `snippet` extracts marked sections of text from a given\nset of input files and saves them elsewhere.\n\nFeatures include:\n- Works on any text file, e.g.\nany coding language by reading from source files\n- Uses customisable markup syntax\n- Writes to templated output (e.g. `.md` code blocks)\n- Hides sections from output\n- Performs validation to help avoid snippets breaking as code changes\n\n## Rationale\nCode documentation usually needs a written example demonstrating use of some code. This example code can however become quite easily outdated as a project evolves or even contain its own errors.\nOne solution is to write the examples as tests which can be run within the test system of choice. This ensures that the code of the examples is always valid and working. `snippet` can then be used to extract the relevant and informative part of the test and put it in a form which can then be rendered by the documentation system, providing fully tested code examples.\n\n## Getting started\n### Prerequisites\n- `snippet` requires Python 3\n\n### Installation\n```\npip install code-snippet\n```\n### Configuration\nPlace a config file in the [toml format](https://github.com/toml-lang/toml)\nin your project directory (e.g. `snippet.toml`). Any value defined in [the config object](https://github.com/ARMmbed/snippet/blob/master/src/snippet/config.py#L8)\ncan be overridden.\n\nAs an example, basic configuration typically includes input and output directories:\n\n```\n[snippet]\ninput_glob = 'tests/unit/*.py'\noutput_dir = 'docs/examples'\n```\n\n### Run\nRun the following command in your project, using the Python interpreter you installed `snippet` to:\n\n```\npython -m snippet\n```\n\nAlternatively, run snippet from anywhere and specify a working directory and config file:\n```\npython -m snippet path/to/root --config=path/to/config.toml\n```\nConfig files can be specified as glob patterns, defaulting to `*.toml`, and can\nbe set multiple times. Multiple files will be loaded in the order specified\nand discovered. Settings loaded last will take precedence.\n\n### Usage\nFor more information about how to use the tool, please have a look at the [Usage page](./USAGE.md)\nThe full CLI options are:\n```\n> python -m snippet --help\nusage: __main__.py [-h] [--config CONFIG] [-v] [dir]\n\npositional arguments:\n dir path to project root, used by any relative paths in loaded\n configs [cwd]\n\noptional arguments:\n -h, --help show this help message and exit\n --config CONFIG paths (or globs) to config files\n -v, --verbosity increase output verbosity\n```\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ARMmbed/snippet", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "code-snippet", "package_url": "https://pypi.org/project/code-snippet/", "platform": "", "project_url": "https://pypi.org/project/code-snippet/", "project_urls": { "Homepage": "https://github.com/ARMmbed/snippet" }, "release_url": "https://pypi.org/project/code-snippet/1.1.0/", "requires_dist": [ "toml", "pystache" ], "requires_python": ">3.4", "summary": "Code snippet extraction", "version": "1.1.0" }, "last_serial": 4953628, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "6d5b6e79110c058083bff4cb31b9d667", "sha256": "db24aefe63fff833de16f00dad08c87d2d778aca0870447c976faaefe4317ced" }, "downloads": -1, "filename": "code_snippet-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6d5b6e79110c058083bff4cb31b9d667", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.4", "size": 13346, "upload_time": "2018-11-07T13:31:02", "url": "https://files.pythonhosted.org/packages/b7/ee/6c857d0995fbdc00374b38915ba653c910667166e4a96e65bb3b9e57fb7b/code_snippet-1.1.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6d5b6e79110c058083bff4cb31b9d667", "sha256": "db24aefe63fff833de16f00dad08c87d2d778aca0870447c976faaefe4317ced" }, "downloads": -1, "filename": "code_snippet-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6d5b6e79110c058083bff4cb31b9d667", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.4", "size": 13346, "upload_time": "2018-11-07T13:31:02", "url": "https://files.pythonhosted.org/packages/b7/ee/6c857d0995fbdc00374b38915ba653c910667166e4a96e65bb3b9e57fb7b/code_snippet-1.1.0-py3-none-any.whl" } ] }