Yeoman generator for a Python app with a command-line interface using cmd
- Installation
- Usage
- Features
- Generators
- Options
- Roadmap
- Contributing
- Changelog
- Author
- License
- Acknowledgments
- Install Node.js.
- Run
npm install -g yo
to install Yeoman using npm. - Run
npm install -g generator-python-cmd
to install generator-python-cmd.
This readme covers the generator. See the README.md in your generated project for information on using the project's code.
- Create a new directory for your project, and enter it.
- From the new project directory, run
yo python-cmd
to generate your new project. - Answer the questions at the prompts to customize your project.
- Run
pip install -r requirements-dev.txt
to install the project's initial development tools, such as Sphinx (see the next section).
Your new project will be set up to use the automatic documentation generator Sphinx. If you stick with this option, you'll do the initial setup with Sphinx's own script.
- If you haven't already, install Sphinx using the
pip
command from the previous section. - Follow the Sphinx tutorial, except for the installation.
- If you run the
sphinx-quickstart
script from your project's root directory, set the "Root path for the documentation" todocs
. - I recommend saying
y
to at least the following extensions (these and other extensions described here):- autodoc - Lets you avoid maintaining duplicate documentation between your code and the Sphinx documents. Also lets you format your docstrings nicely.
- doctest - Tests all the code examples in your documentation, if you put them in doctest blocks.
- coverage - Checks whether your documentation covers your project's whole public API.
- viewcode - Links the documentation of each object to a highlighted version of the object's source code so users can easily examine its implementation.
If you'd like your documentation nicely formatted and available online, you can register your repository with Read the Docs, and they will host the project's documentation. Follow their Getting Started Guide.
The generator creates
- an app.py script for running your application
- an in-app command-line prompt using the cmd library
- a setup.py script for optionally installing your application's package as a library
- a directory (renamed to your package name) to contain your application's package files
- a config directory to house the app's configuration files
- a tests directory for unit tests using pytest
- a docs directory to contain your documentation, ready to be set up by Sphinx
- a readme file to hold basic information on installing, using, and contributing to the project
- an MIT license file
- an EditorConfig file for synchronizing coding style
- a Git ignore file
The generator puts all of that into the following folder structure:
.
|____config
|____docs
|____<package>
| |______init__.py
| |____cli.py
| |____config.py
| |____controller.py
|____tests
| |____context.py
| |____test_app.py
| |____test_controller.py
|____app.py
|____.editorconfig
|____.gitignore
|____LICENSE.md
|____README.md
|____requirements-dev.txt
|____requirements.txt
|____setup.py
Available generators:
- python-cmd (aka python-cmd:app)
Sets up a new Python cmd app, generating all the boilerplate you need to get started.
yo python-cmd
There are currently no command-line options for the generator.
The prompts ask for the following information:
Default: [Name of project folder in title case and with non-word characters replaced by spaces]
The project name. Used in the documentation files and setup.py.
Default: [Name of project folder with non-word characters removed]
The package name. Used in app.py, test files, and setup.py.
Default: UNDEFINED [or automatically saved value]
The project description. Used in the documentation files and setup.py.
Default: UNDEFINED [or automatically saved value]
The author's name. Used in the documentation files and setup.py.
Default: UNDEFINED
The author's email address. Used in the documentation files and setup.py.
To the app templates:
- Add user configuration.
- Add pylama configuration for code linting.
- Add Wheel configuration for packaging.
- Add conda configuration for package and environment management.
- Add pyup configuration for dependency management.
- Add Codecov configuration for code coverage reporting.
- Add Tox configuration for managing test environments.
- Add Travis CI configuration for automatic testing and deployment.
See contributing.md to learn how to contribute to this project. Contributions include bug reports, feature requests, code, and documentation.
See the Releases page for this project on GitHub.
MIT © Andy Culbertson
For details see the LICENSE file.
These sources have helped shape this project's features and documentation:
- Yeoman's various repositories
- generator-python-library
- generator-python-bones
- The in-house ebook production tools at Tyndale House Publishers