diff --git a/README.md b/README.md index cebf6fb..3794775 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,24 @@ -# Render Engine `BasePageParser` +# Cookiecutter Render Engine Custom Parsers -## Installation -You can install this using pip +This [cookiecutter](https://github.com/cookiecutter/cookiecutter) template helps you generate a custom parser for the [Render Engine](https://github.com/render-engine/render-engine). -```sh -pip install {{cookiecutter.project_slug}} -``` -{% if frontmatter %} -## Using Frontmatter - -[Frontmatter](https://github.com/eyeseast/python-frontmatter) is used to pull in attributes from a generated page. - -Some pages will be looking for information that is provided in the frontmatter. All of the attributes defined can be used in the template (which itself can also be defined in the frontmatter or the class itself. - -> **NOTE** -> These attributes **CANNOT** be used in the content itself, but you can use them in the template generation. +## Usage -{% endif %} +1. Install cookiecutter -## Parsing the Data +```bash +pip install cookiecutter +``` -The base parser doesn't is a pass-thru parser meaning the content input will be passed through. +2. Run cookiecutter -```md -# TODO: EXAMPLE OF HOW YOUR DATA IS PARSED +```bash +cookiecutter gh:render-engine/cookiecutter-render-engine-custom-parser ``` -If you generate the page with the following template +3. Answer the questions -```html -
-# TODO: EXAMPLE OF A TEMPLATE -
-``` +4. Replace areas marked with `TODO` in the generated code -it would generate. +We recommend using [VSCode](https://code.visualstudio.com/) with the [TODO Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree) extension to keep track of the `TODO` comments. -```html -# TODO: EXAMPLE OF A GENERATED REPORT -``` diff --git a/cookiecutter.json b/cookiecutter.json new file mode 100644 index 0000000..77f2673 --- /dev/null +++ b/cookiecutter.json @@ -0,0 +1,5 @@ +{ + "project_name": "Your Project Name", + "project_slug": "{{cookiecutter.project_name|lower|replace(' ', '_')|replace('-', '_')}}", + "parser_class": "{{cookiecutter.project_name|title()|replace(' ', '')|replace('-', '')|}}PageParser" +} \ No newline at end of file diff --git a/render_engine_parser/__init__.py b/render_engine_parser/__init__.py deleted file mode 100644 index f31c936..0000000 --- a/render_engine_parser/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .base_parsers import BasePageParser - -__all__ = ["BasePageParser"] diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md new file mode 100644 index 0000000..cebf6fb --- /dev/null +++ b/{{cookiecutter.project_slug}}/README.md @@ -0,0 +1,41 @@ +# Render Engine `BasePageParser` + +## Installation +You can install this using pip + +```sh +pip install {{cookiecutter.project_slug}} +``` +{% if frontmatter %} +## Using Frontmatter + +[Frontmatter](https://github.com/eyeseast/python-frontmatter) is used to pull in attributes from a generated page. + +Some pages will be looking for information that is provided in the frontmatter. All of the attributes defined can be used in the template (which itself can also be defined in the frontmatter or the class itself. + +> **NOTE** +> These attributes **CANNOT** be used in the content itself, but you can use them in the template generation. + +{% endif %} + +## Parsing the Data + +The base parser doesn't is a pass-thru parser meaning the content input will be passed through. + +```md +# TODO: EXAMPLE OF HOW YOUR DATA IS PARSED +``` + +If you generate the page with the following template + +```html +
+# TODO: EXAMPLE OF A TEMPLATE +
+``` + +it would generate. + +```html +# TODO: EXAMPLE OF A GENERATED REPORT +``` diff --git a/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/__init__.py new file mode 100644 index 0000000..f578dea --- /dev/null +++ b/{{cookiecutter.project_slug}}/__init__.py @@ -0,0 +1,3 @@ +from .parse import {{cookiecutter.parser_name}} + +__all__ = ["BasePageParser"] diff --git a/render_engine_parser/base_parsers.py b/{{cookiecutter.project_slug}}/parser.py similarity index 100% rename from render_engine_parser/base_parsers.py rename to {{cookiecutter.project_slug}}/parser.py