Skip to content

A Yeoman generator for a Python app with a command-line interface using cmd

License

Notifications You must be signed in to change notification settings

thinkulum/generator-python-cmd

Repository files navigation

Python cmd App Generator

NPM version Build Status Test Coverage Dependency Status Dev Dependency Status

Yeoman generator for a Python app with a command-line interface using cmd

Installation

  1. Install Node.js.
  2. Run npm install -g yo to install Yeoman using npm.
  3. Run npm install -g generator-python-cmd to install generator-python-cmd.

Usage

This readme covers the generator. See the README.md in your generated project for information on using the project's code.

Generating a Project

  1. Create a new directory for your project, and enter it.
  2. From the new project directory, run yo python-cmd to generate your new project.
  3. Answer the questions at the prompts to customize your project.
  4. Run pip install -r requirements-dev.txt to install the project's initial development tools, such as Sphinx (see the next section).

Setting up Documentation

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.

  1. If you haven't already, install Sphinx using the pip command from the previous section.
  2. Follow the Sphinx tutorial, except for the installation.
  3. If you run the sphinx-quickstart script from your project's root directory, set the "Root path for the documentation" to docs.
  4. 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.

Features

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

Generators

Available generators:

App

Sets up a new Python cmd app, generating all the boilerplate you need to get started.

yo python-cmd

Options

There are currently no command-line options for the generator.

The prompts ask for the following information:

projectName

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.

packageName

Default: [Name of project folder with non-word characters removed]

The package name. Used in app.py, test files, and setup.py.

projectDesc

Default: UNDEFINED [or automatically saved value]

The project description. Used in the documentation files and setup.py.

author

Default: UNDEFINED [or automatically saved value]

The author's name. Used in the documentation files and setup.py.

authorEmail

Default: UNDEFINED

The author's email address. Used in the documentation files and setup.py.

Roadmap

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.

Contributing

See contributing.md to learn how to contribute to this project. Contributions include bug reports, feature requests, code, and documentation.

Changelog

See the Releases page for this project on GitHub.

Author

License

MIT © Andy Culbertson

For details see the LICENSE file.

Acknowledgments

These sources have helped shape this project's features and documentation:

About

A Yeoman generator for a Python app with a command-line interface using cmd

Resources

License

Stars

Watchers

Forks

Packages

No packages published