Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Add docs and git work in post hook.
Browse files Browse the repository at this point in the history
Now uses GitPython to init the repo after templateing and then add
astropy_helpers as a submodule.
  • Loading branch information
Cadair committed Jan 13, 2017
1 parent ca28323 commit 5fd80bb
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 5 deletions.
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Compiled files
*.py[cod]
*.a
*.o
*.so
__pycache__

# Ignore .c files by default to avoid including generated code. If you want to
# add a non-generated .c extension, use `git add -f filename.c`.
*.c

# Other generated files
*/version.py
*/cython_version.py
htmlcov
.coverage
MANIFEST
.ipynb_checkpoints

# Sphinx
docs/api
docs/_build

# Eclipse editor project files
.project
.pydevproject
.settings

# Pycharm editor project files
.idea

# Packages/installer info
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
distribute-*.tar.gz

# Other
.cache
.tox
.*.sw[op]
*~
.project
.pydevproject
.settings

# Mac OSX
.DS_Store
2 changes: 2 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"use_appveyor_ci": "y",
"use_read_the_docs": "y",
"sphinx_theme": "astropy-boostrap",
"initialize_git_repo": "y",
"astropy_helpers_version": "v1.3",
"_parent_project": "astropy",
"_install_requires": "['astropy']",
"_copy_without_render": [
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = AstropyPackageTemplate
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
116 changes: 116 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Astropy Package Template documentation build configuration file, created by
# sphinx-quickstart on Wed Jan 11 11:09:48 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
needs_sphinx = '1.2'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.intersphinx']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'Astropy Package Template'
copyright = '2017, The Astropy Developers'
author = 'The Astropy Developers'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.2'
# The full version, including alpha/beta/rc tags.
release = '1.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

rst_epilog = """
.. _Astropy: http://astropy.org
"""
# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.

import astropy_sphinx_theme
html_theme_path = astropy_sphinx_theme.get_html_theme_path()
html_theme = 'bootstrap-astropy'

html_favicon = os.path.join(html_theme_path[0], html_theme, 'static',
'astropy_logo.ico')

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

html_sidebars = {
'**': ['localtoc.html'],
'search': [],
'genindex': [],
'py-modindex': [],
}

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'AstropyPackageTemplatedoc'


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None,
'http://docs.astropy.org/en/stable/': None}
58 changes: 58 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Welcome to Astropy Package Template's documentation!
====================================================

The Astropy package template is designed to help quickly create new Python packages within the Astropy ecosystem.

Getting Started
---------------

The Astropy Package template uses the `Cookiecutter
<http://cookiecutter.readthedocs.io/>`_ project to make it easier to get
started. To use the package template you need cookiecutter installed, depending
on how you have Python installed it can be obtained through either pip or
conda::

pip install cookiecutter

or::

conda install -c conda-forge cookiecutter


Cookiecutter works by taking a template (in this case the Astropy Package
Template) and asking you a series of questions to create a set of files and
folders where your answers to the questions are pre-filled into the correct
places. The package template uses this to allow you to specify things like your
projects name as well as choose what parts and features of the template you want
to use.

To start a package with the package template run::

cookiecutter gh:astropy/package-template

This will ask you a series of questions, and result in a directory inside your
current working directory that has the name of your project.

.. rubric:: Metadata Keywords:

* First matching:
1. ``obsrvtry``
2. ``telescop``
3. Default: ``""``
* ``waveunit`` Default: `~astropy.units.one`

.. toctree::
:maxdepth: 2
:caption: Contents:

options
updating



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
24 changes: 24 additions & 0 deletions docs/options.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Options during Setup
====================

To use the package template run ``cookiecutter gh:astropy/package-template``,
once you have run this command you will be asked a series of questions. Below is
a description of each of the prompts.

1. ``package_name``: This is a human readable name for your package, like 'Astropy' or 'SunPy'.
2. ``module_name``: This is the name of your python package i.e. 'astropy' or 'sunpy'.
3. ``short_description``: This is a one sentence description of your package.
4. ``long_description``: This is a multi-line description of your package.
5. ``author_name``: The name or names of the authors.
6. ``author_email``: A contact email for the authors.
7. ``license``: The license of your project.
8. ``project_url``: Project website.
9. ``include_example_code``: This includes a set of example python and cython files showing you how to use the package template. If you choose 'n' then none of this will be included and you will have to populate the directory structure before you can import the package.
10. ``include_cextern_folder``: The cextern folder should be used if you are including non-python C code.
11. ``edit_on_github_extension``: Set to "True" to enable the edit on GitHub sphinx extension.
12. ``github_project``: This is the GitHub identifier for the edit on GitHub extension and the changelog link extension.
13. ``project_version``: The current version number of your project.
14. ``use_travis_ci``: If 'y' the template will include an example ``.travis.yml`` file for the Travis CI service.
15. ``use_appveyor_ci``: If 'y' the template will include an example ``appveyor.yml`` file for the Appveyor CI service.
16. ``use_read_the_docs``: If 'y' the ``read_the_docs.yml`` and ``.rtd-environment.yml`` files will be included for using conda on Read the Docs.
17. ``sphinx_theme``: The value of the ``html_theme`` variable in the sphinx configuration file.
8 changes: 8 additions & 0 deletions docs/updating.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Updating Your Package
=====================

Once you have setup your project there will come a time when some things in the
package template change, new versions of ``astropy_helpers`` or updates to the
infrastructure you want to utilise. Updating your package with these changes is
a balance between maintaining parity with the original template and customising
your project to your needs.
22 changes: 20 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
def remove_file(filepath):
os.remove(os.path.join(PROJECT_DIRECTORY, filepath))


def remove_dir(filepath):
shutil.rmtree(os.path.join(PROJECT_DIRECTORY, filepath))



if __name__ == '__main__':

if '{{ cookiecutter.use_travis_ci }}' != 'y':
Expand All @@ -26,7 +26,7 @@ def remove_dir(filepath):
remove_file('.rtd-environment.yml')
remove_file('readthedocs.yml')

if '{{ cookiecutter.cextern_folder }}' != 'y':
if '{{ cookiecutter.include_cextern_folder }}' != 'y':
remove_dir("cextern")

if '{{ cookiecutter.include_example_code }}' != 'y':
Expand All @@ -35,3 +35,21 @@ def remove_dir(filepath):
remove_file('{{ cookiecutter.module_name }}/example_mod.py')
remove_file('{{ cookiecutter.module_name }}/tests/test_example.py')

if '{{ cookiecutter.initialize_git_repo }}' == 'y':
from git import Repo

new_repo = Repo.init(PROJECT_DIRECTORY)
new_repo.git.add('.')
new_repo.index.commit(
"Creation of {{ cookiecutter.package_name }} from astropy package template"
)

if '{{ cookiecutter.astropy_helpers_version }}':
Repo.create_submodule(
new_repo, "astropy_helpers", "astropy_helpers",
"https://github.com/astropy/astropy-helpers.git",
"{{ cookiecutter.astropy_helpers_version }}")
new_repo.submodules[0].update()
new_repo.index.commit(
"Initialize astropy_helpers at version {{ cookiecutter.astropy_helpers_version }}"
)
3 changes: 0 additions & 3 deletions {{ cookiecutter.package_name }}/.gitmodules

This file was deleted.

0 comments on commit 5fd80bb

Please sign in to comment.