Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option To Use Markdown README #46

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
"GNU GPL v3.0",
"Apache Software License 2.0",
"Mozilla Public License 2.0"
],
"readme_format": [
"reStructred Text (.rst)",
"Markdown (.md)"
]
}
23 changes: 23 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import shutil
import sys

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("post_gen_project")
Expand Down Expand Up @@ -44,7 +45,29 @@ def remove_temp_folders(temp_folders):
logger.info("Remove temporary folder: %s", folder)
shutil.rmtree(folder)

def apply_readme_file_extension(extension):
if extension.endswith("(.rst)"):
extension = ".rst"
elif extension.endswith("(.md)"):
extension = ".md"
else:
logger.warning("README file extension unknown: %s", extension)
sys.exit(1)

readme_path = os.path.join(
os.getcwd(),
"README.template"
)

if os.path.exists(readme_path):
new_path = os.path.join(
os.getcwd(),
"README" + extension
)
os.rename(readme_path, new_path)


if __name__ == "__main__":
apply_readme_file_extension("{{cookiecutter.readme_format}}")
move_docs_files("{{cookiecutter.docs_tool}}", DOCS_FILES_BY_TOOL, DOCS_SOURCES)
remove_temp_folders(ALL_TEMP_FOLDERS)
80 changes: 0 additions & 80 deletions pytest-{{cookiecutter.plugin_name}}/README.rst

This file was deleted.

152 changes: 152 additions & 0 deletions pytest-{{cookiecutter.plugin_name}}/README.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{% if cookiecutter.readme_format == "reStructred Text (.rst)" %}
{%- from "macros/rst" import doc_title, doc_subtitle -%}

{{ doc_title('pytest-' + cookiecutter.plugin_name) }}

.. image:: https://img.shields.io/pypi/v/pytest-{{cookiecutter.plugin_name}}.svg
:target: https://pypi.org/project/pytest-{{cookiecutter.plugin_name}}
:alt: PyPI version

.. image:: https://img.shields.io/pypi/pyversions/pytest-{{cookiecutter.plugin_name}}.svg
:target: https://pypi.org/project/pytest-{{cookiecutter.plugin_name}}
:alt: Python versions

.. image:: https://travis-ci.org/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}.svg?branch=master
:target: https://travis-ci.org/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}
:alt: See Build Status on Travis CI

.. image:: https://ci.appveyor.com/api/projects/status/github/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}?branch=master
:target: https://ci.appveyor.com/project/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}/branch/master
:alt: See Build Status on AppVeyor

{{cookiecutter.short_description}}

----

This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.


Features
--------

* TODO


Requirements
------------

* TODO


Installation
------------

You can install "pytest-{{cookiecutter.plugin_name}}" via `pip`_ from `PyPI`_::

$ pip install pytest-{{cookiecutter.plugin_name}}


Usage
-----

* TODO

Contributing
------------
Contributions are very welcome. Tests can be run with `tox`_, please ensure
the coverage at least stays the same before you submit a pull request.

License
-------

Distributed under the terms of the `{{cookiecutter.license}}`_ license, "pytest-{{cookiecutter.plugin_name}}" is free and open source software


Issues
------

If you encounter any problems, please `file an issue`_ along with a detailed description.

.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
.. _`@hackebrot`: https://github.com/hackebrot
.. _`MIT`: http://opensource.org/licenses/MIT
.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause
.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin
.. _`file an issue`: https://github.com/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project

{# #}
{# ----- END rST SECTION ----- #}
{# #}

{% elif cookiecutter.readme_format == "Markdown (.md)" %}
# "pytest-"{{ cookiecutter.plugin_name }}

[![PyPI version](https://img.shields.io/pypi/v/pytest-{{cookiecutter.plugin_name}}.svg)](https://pypi.org/project/pytest-{{cookiecutter.plugin_name}})

[![Python versions](https://img.shields.io/pypi/pyversions/pytest-{{cookiecutter.plugin_name}}.svg)](https://pypi.org/project/pytest-{{cookiecutter.plugin_name}})

[![See Build Status on Travis CI](https://travis-ci.org/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}.svg?branch=master)](https://travis-ci.org/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}})

[![See Build Status on AppVeyor](https://ci.appveyor.com/api/projects/status/github/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}?branch=master)](https://ci.appveyor.com/project/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}/branch/master)

{{cookiecutter.short_description}}


This [pytest][pytest] plugin was generated with [Cookiecutter][cookiecutter] along with [@hackebrot][hackebrot]'s [cookiecutter-pytest-plugin][plugin-template] template.

[cookiecutter]: https://github.com/audreyr/cookiecutter
[hackebrot]: https://github.com/hackebrot
[pytest]: https://github.com/pytest-dev/pytest
[plugin-template]: https://github.com/pytest-dev/cookiecutter-pytest-plugin

## Features

* TODO

## Requirements

* TODO

## Installation

You can install "pytest-{{cookiecutter.plugin_name}}" via [pip][pip] from [PyPI][PyPI]

```
$ pip install pytest-{{cookiecutter.plugin_name}}
```

[pip]: https://pypi.python.org/pypi/pip
[PyPI]: https://pypi.org/project/pytest-{{cookiecutter.plugin_name}}

## Usage

* TODO

## Contributing

Contributions are very welcome. Tests can be run with [tox][tox], please ensure
the coverage at least stays the same before you submit a pull request.

[tox]: https://tox.readthedocs.io/en/latest/

## License

Distributed under the terms of the [{{cookiecutter.license}}][{{cookiecutter.license}}] license, "pytest-{{cookiecutter.plugin_name}}" is free and open source software

## Issues

If you encounter any problems, please [file an issue][issue-link] along with a detailed description.

[MIT]: http://opensource.org/licenses/MIT
[BSD-3]: http://opensource.org/licenses/BSD-3-Clause
[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt
[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0
[issue-link]: https://github.com/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}/issues

{% endif %}