{ "info": { "author": "Jim Anderson", "author_email": "jima.coding@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "# ![license_markplates](https://raw.githubusercontent.com/jima80525/markplates/master/license_markplates.jpg)\n\n# MarkPlates\n\n> A templating utility for keeping code included in Markdown documents in sync with the original source.\n\n[![CircleCI](https://circleci.com/gh/jima80525/markplates.svg?style=svg)](https://circleci.com/gh/jima80525/markplates) ![black](https://img.shields.io/badge/code%20style-black-000000.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![pyup.io](https://pyup.io/repos/github/jima80525/markplates/shield.svg)](https://pyup.io/account/repos/github/jima80525/markplates/) [![PyPI version](https://badge.fury.io/py/markplates.svg)](https://badge.fury.io/py/markplates) [![Coverage Status](https://coveralls.io/repos/github/jima80525/markplates/badge.svg?branch=master)](https://coveralls.io/github/jima80525/markplates?branch=master)\n\nThe problem I hope to solve is to simplify keeping external files up to date with markdown documents that contain them. This happens to me frequently when an editor makes a suggestion to an article that will modify the underlying code it is quoting.\n\n## Installing\n\nYou can download and install the latest version of MarkPlates from the PyPI with this command:\n\n```bash\n$ pip install --upgrade markplates\n```\n\nMarkPlates is currently tested against Python 3.6 and Python 3.7.\n\n## Usage\n\nRunning `markplates` is as simple as handing it a file:\n\n```bash\n$ markplates template.mdt\n```\n\nThis will process the template in `template.mdt`, filling it in with data specified in the template.\n\nThe `examples` directory has the `simple.mdt` template:\n\n```markdown\n# Sample MarkPlates Template\n{{ set_path(\"./examples\") }}\n\nThis is an example of importing an entire file (minus the first line):\n{{ import_source(\"testfile.py\") }}\n\nWhile this silly example imports some of the lines from the file, demonstrating ranges:\n{{ import_source(\"testfile.py\", [5, \"2\", 3, \"8-$\", ]) }}\n\n{{ import_repl(\n\"\"\"\ndef func(x):\n if x:\n print(x)\n\nfunc(True)\nfunc(False) \"\"\") }}\n```\n\nThis demonstrates setting the path and pulling in some of the lines of a file. You can also examine the `README.mdt` file in this library which is used to create this `README.md`.\n\nTo use on your own project create a markdown document with special tags to indicate a `markplates` function call. The delimiter for these tags is `{{` function goes here `}}`.\n\n> **Note:** if you need to add `{{` characters which should not be processed as a template, you can put them in a `{{ '' }}` block to escape them. Template processing is done with `Jinja2` so Markplates uses the same escape sequences.\n\n`Markplates` supports these functions:\n\n* `set_path(\"path/to/source/files\")`\n* `import_source(\"source_file_name\", [list of line number ranges])`\n* `import_function(\"source_file_name\", \"function_name\")`\n* `import_repl(\"code to run in repl\")`\n\n### `set_path()`\n\nThe `set_path()` function allows you to specify the base directory to use when searching for source files. Each call to this function will apply from that point in the template down.\n\nThe path must be included in single or double qoutes. If not specified, the path defaults to \".\", the current directory.\n\nExamples:\n\n\n```\n{{set_path(\".\")}} #sets path to the default\n{{set_path(\"/home/user/my/project\")}} # points the path to your project\n```\n\nThe `set_path()` command is not required as all other functions will take full paths to files.\n\n### `import_source()`\n\nThe `import_source()` function will pull in the contents of a source file. Optional line number ranges can be specified (see description below). The filename must be in quotes.\n\nIf no line number ranges are specified, the first line of the file will be omitted. This is to prevent the `#!/usr/bin/env python` line from cluttering the markdown article. If you want to include the first line, use the range: `1-$`.\n\nExamples:\n\n```\n{{import_source(\"__main__.py\")}} # includes all but line 1 from `__main__.py` file\n{{import_source(\"__main__.py\", [\"1-$\",])}} # imports all lines from `__main__.py`\n{{import_source(\"__main__.py\", [1, \"3\", \"5-$\"])}} # imports all lines except lines 2 and 4 from `__main__.py`\n```\n\n`MarkPlates` will display an error message to `stderr` if a file is not found.\n\n### `import_function()`\n\nThe `inport_function` function will search the source file and include only the specified function. If there are multiple functions with the same name in the source_file, only the first will be included (and you shouldn't have multiple functions with the same name anyway!).\n\nWhitespace following the function will not be included.\n\nExamples:\n\n```\n{{import_function(\"__main__.py\", \"condense_ranges\")}} # imports the function named `condense_ranges` from `__main__.py`\n```\n\n`MarkPlates` handles nested functions, included any functions nested in the specified function.\n\n### `import_repl()`\n\nThe `import_repl` function takes the input parameter and splits it into separate lines. Each line of the input will be run in a REPL with the `stdout` and `stderr` captured to insert into the final output. The result should appear similar to a copy-paste from running the same commands manually.\n\nThere is an exception, however. Blank input lines are used for spacing and will not display the `>>>` prompt one would normally see in the REPL.\n\nExample:\n\n```\n{{import_repl(\n\"\"\"\ndef func(x):\n if x:\n print(x)\n\nfunc(True)\nfunc(False) \"\"\") }}\n```\n\n\nOutput:\n```\n>>> def func(x):\n... if x:\n... print(x)\n\n>>> func(True)\nTrue\n>>> func(False)\n\n```\n\n### Line Number Ranges\n\nLine number ranges allow you to specify which lines you want to include from the source file. Ranges can be in the following form:\n\n* 3 or \"3\" : an integer adds just that line from the input\n\n* \"5-7\" : a range adds lines between start and end inclusive (so 5, 6, 7)\n\n* \"10-$\" : an unlimited range includes start line to the end of the file\n\n> **Note:** LINE NUMBERING STARTS AT 1!\n\n## Features to Come\n\nI'd like to add:\n\n* Capturing the results of a shell command and inserting into the file\n* Copying the resultant Markdown file to the clipboard\n* Running `black` over the included Python source\n* Windows and Mac testing/support\n\n## Interested?\n\nLet me know! If you're interested in the results or would like to help out, please raise an issue and I'll be in touch!\n\n## Release History\n\n* 1.1.0 Added `import_repl` functionality\n\n* 1.0.0 Initial release\n\nLicense plate graphic thanks to [ACME License Maker](https://www.acme.com/licensemaker/)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jima80525/markplates", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "markplates", "package_url": "https://pypi.org/project/markplates/", "platform": "", "project_url": "https://pypi.org/project/markplates/", "project_urls": { "Homepage": "https://github.com/jima80525/markplates" }, "release_url": "https://pypi.org/project/markplates/1.1.1/", "requires_dist": [ "Click", "Jinja2" ], "requires_python": ">=3.6.0", "summary": "Inject code snippets into your Markdown docs", "version": "1.1.1" }, "last_serial": 5200173, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0fb16fe0c3f7db84b5575ef9004ff578", "sha256": "43acbd3349a78bffd9955d7cd65330b31f83574a9ead31cc43fa310ade7b15d1" }, "downloads": -1, "filename": "markplates-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0fb16fe0c3f7db84b5575ef9004ff578", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 6804, "upload_time": "2019-04-04T01:55:58", "url": "https://files.pythonhosted.org/packages/b9/1b/328cb3e878522eae028e773c960dd467ba3b5dea698ebd105940493038ee/markplates-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ec99fa20413154a6b5e7043ba1b87531", "sha256": "fe7616b05a72eddba11b7d9db372c3e4361703cae5644bc7ea540eaa90a7260b" }, "downloads": -1, "filename": "markplates-1.0.0.tar.gz", "has_sig": false, "md5_digest": "ec99fa20413154a6b5e7043ba1b87531", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 5542, "upload_time": "2019-04-04T01:56:00", "url": "https://files.pythonhosted.org/packages/8c/c1/23f82cd3278ceb6131bc9d9de90674bf1f8c370f0c84f7459b9cccab93ad/markplates-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "c654c31a28dd74d81e5a5cce0ce71e21", "sha256": "8485899eebd3d6e1a715ae89d2bfd6c0529252138f3e7760ac89251345117cd8" }, "downloads": -1, "filename": "markplates-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c654c31a28dd74d81e5a5cce0ce71e21", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 7586, "upload_time": "2019-04-27T14:27:26", "url": "https://files.pythonhosted.org/packages/15/89/82a50470f31a9cef49ff961876db8d221c6e536f9364c102a603ac766388/markplates-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a6f69dd136396637c6bf80942f6f740e", "sha256": "421335357f78c86b049162e1a8e272cbbb072c1de073d93c7de7c1556bac9c3f" }, "downloads": -1, "filename": "markplates-1.1.0.tar.gz", "has_sig": false, "md5_digest": "a6f69dd136396637c6bf80942f6f740e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6436, "upload_time": "2019-04-27T14:27:31", "url": "https://files.pythonhosted.org/packages/14/aa/6ccb33e5cb507bd60eb8249db97dd9fcf4954ba0cb1cbd68ef77f84bbae1/markplates-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "cf39831aeb14130705307a54404c3a01", "sha256": "ed607df36b7a7180de2330307342426832173a9f39b9b98ca6cb9c0860a81439" }, "downloads": -1, "filename": "markplates-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cf39831aeb14130705307a54404c3a01", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 7690, "upload_time": "2019-04-28T17:25:55", "url": "https://files.pythonhosted.org/packages/09/42/ff4fdfda5ae7f29ef73df6f06d72d042c124c83485fcfe8983f404e46aaa/markplates-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fa25214b609de1a294c4245a2c8c812e", "sha256": "13ac284c1a59a0551cb3a5d9b6604242176e1234d53c5cc09538f85d598d943e" }, "downloads": -1, "filename": "markplates-1.1.1.tar.gz", "has_sig": false, "md5_digest": "fa25214b609de1a294c4245a2c8c812e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6542, "upload_time": "2019-04-28T17:25:59", "url": "https://files.pythonhosted.org/packages/cd/03/ab812e4ced00080d741aa266b04a37fb143cf780db62132090e6d6afdf2f/markplates-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cf39831aeb14130705307a54404c3a01", "sha256": "ed607df36b7a7180de2330307342426832173a9f39b9b98ca6cb9c0860a81439" }, "downloads": -1, "filename": "markplates-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cf39831aeb14130705307a54404c3a01", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 7690, "upload_time": "2019-04-28T17:25:55", "url": "https://files.pythonhosted.org/packages/09/42/ff4fdfda5ae7f29ef73df6f06d72d042c124c83485fcfe8983f404e46aaa/markplates-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fa25214b609de1a294c4245a2c8c812e", "sha256": "13ac284c1a59a0551cb3a5d9b6604242176e1234d53c5cc09538f85d598d943e" }, "downloads": -1, "filename": "markplates-1.1.1.tar.gz", "has_sig": false, "md5_digest": "fa25214b609de1a294c4245a2c8c812e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6542, "upload_time": "2019-04-28T17:25:59", "url": "https://files.pythonhosted.org/packages/cd/03/ab812e4ced00080d741aa266b04a37fb143cf780db62132090e6d6afdf2f/markplates-1.1.1.tar.gz" } ] }