0.1.0 • Published 6 years ago

generator-python-cmd v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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.

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 nose2
  • 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
  • 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.py
|____app.py
|____.gitignore
|____LICENSE.md
|____README.md
|____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

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

author

Default: UNDEFINED

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 generator:

  • Add configuration saving.
  • Add command-line options.
  • Add EditorConfig configuration for synchronizing coding style.

To the app templates:

  • Enable app commands from the command line.
  • Add user configuration.
  • Add EditorConfig configuration for synchronizing coding style.
  • Add pylama configuration for code linting.
  • Switch to pytest for testing.
  • 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.