From ca789eaf7662889fc8eb0a2f459d547f791719b5 Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Dec 16 2016 20:37:51 +0000 Subject: Add a documentation project Signed-off-by: Jeremy Cline --- diff --git a/README.md b/README.md index 9770f05..948cc3f 100644 --- a/README.md +++ b/README.md @@ -3,72 +3,8 @@ The Fedora registry endpoint. -## Development +## Contributing -### Contribution guidelines - -Before you submit a pull request to fegistry, please ensure that it meets these criteria: - -* All tests must pass. -* Code should have 100% test coverage. This one is particularly important, as we don't want to - deploy any broken code into production. -* Functions, methods, and classes should have docblocks that explain what the code block is, and - describing any parameters it accepts and what it returns (if anything). -* Code should follow [PEP-8](https://www.python.org/dev/peps/pep-0008). You can use the - ```flake8``` utility to automatically check your code. There is a - ```fegistry.tests.test_style.TestStyle.test_code_with_flake8``` test, which enforced PEP-8 on the - codebase. - - -### Development environment - -[Vagrant](https://www.vagrantup.com) allows contributors to get quickly up and running with a -development environment by automatically configuring a virtual machine. Before you get -started, ensure that your host machine has virtualization extensions enabled in its BIOS so the -guest doesn't go slower than molasses. To get started, simply -use these commands: - -``` - $ sudo dnf install ansible libvirt vagrant-libvirt vagrant-sshfs - $ sudo systemctl enable libvirtd - $ sudo systemctl start libvirtd - $ cp Vagrantfile.example Vagrantfile - # Make sure your fegistry checkout is your shell's cwd - $ vagrant up -``` - -fegistry is now running in the guest, and port 5000 has been forwarded on your host: - -``` - $ curl -i http://localhost:5000/v2/ - HTTP/1.0 200 OK - Content-Type: application/json - Content-Length: 2 - Docker-Distribution-API-Version: registry/2.0 - Server: Werkzeug/0.11.10 Python/3.5.2 - Date: Thu, 15 Dec 2016 22:04:33 GMT - - {} -``` - -You can use ```vagrant ssh``` to ssh into the guest if you like. Inside the guest environment, you -will find the code shared at ```/home/vagrant/fegistry```. There are some convenient bash aliases: - -```flog```: Display the development server's log. You can pass a ```-f``` flag to continuously - display the log. -```frestart```: Restart the development server. The development server does automatically pick up - code changes, so you shouldn't need this much. -```fstart```: Start the development server. -```fstop```: Stop the development server. -```ftest```: Run the test suite. - - -```vagrant ssh``` also accepts a ```-c``` flag that allows you to run a command in the guest. For -example, you can run the tests wtih ```vagrant ssh -c ftest```. - -When you are done with your Vagrant guest, you can destroy it permanently by running this command on -the host: - -``` - $ vagrant destroy -``` +Contributions are welcome! Please consult our +[contribution guidelines](https://docs.pagure.org/fegistry/contributing.html) +to get started. diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..0eae3a5 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = fegistry +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) \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..50c5fae --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# fegistry documentation build configuration file, created by +# sphinx-quickstart on Fri Dec 16 14:34:38 2016. +# +# 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 fegistry + + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# 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.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', + 'sphinxcontrib.napoleon', +] + +# 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', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'fegistry' +copyright = '2016, Jeremy Cline' +author = 'Jeremy Cline' + +# 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 = '.'.join(fegistry.__version__.split('.')[:2]) +# The full version, including alpha/beta/rc tags. +release = fegistry.__version__ + +# 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 + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# 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'] + + +# -- Options for HTMLHelp output ------------------------------------------ + +# Output file base name for HTML help builder. +htmlhelp_basename = 'fegistrydoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'fegistry.tex', 'fegistry Documentation', + 'Jeremy Cline', 'manual'), +] + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'fegistry', 'fegistry Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'fegistry', 'fegistry Documentation', + author, 'fegistry', 'One line description of project.', + 'Miscellaneous'), +] diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..a235064 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1,66 @@ +Development Guide +================= + +Contribution guidelines +----------------------- + +Before you submit a pull request to fegistry, please ensure that it meets these criteria: + +* All tests must pass. +* Code should have 100% test coverage. This one is particularly important, as we don't want to + deploy any broken code into production. +* Functions, methods, and classes should have docblocks that explain what the code block is, and + describing any parameters it accepts and what it returns (if anything). +* Code should follow `PEP-8 `_. You can use the + ``flake8`` utility to automatically check your code. There is a + ``fegistry.tests.test_style.TestStyle.test_code_with_flake8`` test, which enforced PEP-8 on the + codebase. + + +Development environment +----------------------- + +`Vagrant `_ allows contributors to get quickly up and running with a +development environment by automatically configuring a virtual machine. Before you get +started, ensure that your host machine has virtualization extensions enabled in its BIOS so the +guest doesn't go slower than molasses. To get started, simply +use these commands:: + + $ sudo dnf install ansible libvirt vagrant-libvirt vagrant-sshfs + $ sudo systemctl enable libvirtd + $ sudo systemctl start libvirtd + $ cp Vagrantfile.example Vagrantfile + # Make sure your fegistry checkout is your shell's cwd + $ vagrant up + +fegistry is now running in the guest, and port 5000 has been forwarded on your host:: + + $ curl -i http://localhost:5000/v2/ + HTTP/1.0 200 OK + Content-Type: application/json + Content-Length: 2 + Docker-Distribution-API-Version: registry/2.0 + Server: Werkzeug/0.11.10 Python/3.5.2 + Date: Thu, 15 Dec 2016 22:04:33 GMT + + {} + +You can use ``vagrant ssh`` to ssh into the guest if you like. Inside the guest environment, you +will find the code shared at ``/home/vagrant/fegistry``. There are some convenient bash aliases:: + + flog: Display the development server's log. You can pass a ``-f`` flag to continuously + display the log. + frestart: Restart the development server. The development server does automatically pick up + code changes, so you shouldn't need this much. + fstart: Start the development server. + fstop: Stop the development server. + ftest: Run the test suite. + + +``vagrant ssh`` also accepts a ``-c`` flag that allows you to run a command in the guest. For +example, you can run the tests wtih ``vagrant ssh -c ftest``. + +When you are done with your Vagrant guest, you can destroy it permanently by running this command on +the host:: + + $ vagrant destroy diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..6a3c7d0 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,23 @@ +.. fegistry documentation master file, created by + sphinx-quickstart on Fri Dec 16 14:34:38 2016. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Fegistry +======== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + contributing + reference/index + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/reference/index.rst b/docs/reference/index.rst new file mode 100644 index 0000000..b61410d --- /dev/null +++ b/docs/reference/index.rst @@ -0,0 +1,21 @@ +Reference +========= + +.. automodule:: fegistry + :members: + :undoc-members: + :show-inheritance: + +.. contents:: + :local: + :backlinks: none + + +Views +----- + +.. automodule:: fegistry.views + :members: + :undoc-members: + :show-inheritance: + diff --git a/fegistry/__init__.py b/fegistry/__init__.py index abc99f0..8eda8a9 100644 --- a/fegistry/__init__.py +++ b/fegistry/__init__.py @@ -13,4 +13,9 @@ # # You should have received a copy of the GNU General Public License # along with Foobar. If not, see . +""" +Fegistry is a small flask application designed to handle requests +for Fedora containers. +""" + __version__ = '0.0.0' diff --git a/fegistry/views.py b/fegistry/views.py index cdd2a72..d5d39a7 100644 --- a/fegistry/views.py +++ b/fegistry/views.py @@ -22,7 +22,13 @@ app = flask.Flask(__name__) @app.after_request def add_docker_headers(response): """ - Add the necssary Docker headers to every response. + Add the necessary Docker headers to every response. + + Args: + response (flask.Response): The :class:`flask.Response` to modify + + Returns: + flask.Response: The modified flask response """ response.headers['Docker-Distribution-API-Version'] = 'registry/2.0' return response @@ -32,5 +38,8 @@ def add_docker_headers(response): def v2(): """ Answer the GET /v2/ API call with {}. + + Returns: + flask.Response: A JSON response """ return flask.json.jsonify({}) diff --git a/setup.py b/setup.py index f0f1ad7..66904a8 100644 --- a/setup.py +++ b/setup.py @@ -48,4 +48,5 @@ setup( maintainer_email=MAINTAINER_EMAIL, platforms=PLATFORMS, url=URL, keywords='fedora', packages=find_packages(exclude=('fegistry.tests', 'fegistry.tests.*')), include_package_data=True, zip_safe=False, install_requires=['flask'], - tests_require=['flake8', 'mock', 'nose', 'nose-cov'], test_suite="nose.collector") + tests_require=['flake8', 'mock', 'nose', 'nose-cov', 'sphinxcontrib-napoleon'], + test_suite="nose.collector")