Skip to content

Commit

Permalink
Add docs (fix #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
TROUVERIE Joachim committed Apr 16, 2018
1 parent 0c90973 commit cecb112
Show file tree
Hide file tree
Showing 10 changed files with 410 additions and 4 deletions.
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 = pybeeryaml
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)
3 changes: 3 additions & 0 deletions docs/_static/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a.reference {
border-bottom: 0px;
}
22 changes: 22 additions & 0 deletions docs/api/pybeeryaml.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
API
===

Module contents
---------------

.. automodule:: pybeeryaml
:members:
:undoc-members:
:show-inheritance:


Meta
----

pybeeryaml.meta module
----------------------

.. automodule:: pybeeryaml.meta
:members:
:undoc-members:
:show-inheritance:
166 changes: 166 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config

# -- Path setup --------------------------------------------------------------

# 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
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'pybeeryaml'
copyright = '2018, TROUVERIE Joachim'
author = 'TROUVERIE Joachim'

# The short X.Y version
version = '1.0'
# The full version, including alpha/beta/rc tags
release = '1.0'


# -- 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.viewcode',
]

# 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'

# 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 pattern also affects 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'


# -- 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 = 'flask'

html_context = {
"css_files": ["_static/index.css"]
}

# 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 = {
"github_fork": "j0ack/pybeeryaml",
}

# 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']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


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

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


# -- 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, 'pybeeryaml.tex', 'pybeeryaml Documentation',
'TROUVERIE Joachim', '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, 'pybeeryaml', 'pybeeryaml 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, 'pybeeryaml', 'pybeeryaml Documentation',
author, 'pybeeryaml', 'One line description of project.',
'Miscellaneous'),
]


# -- Extension configuration -------------------------------------------------
23 changes: 23 additions & 0 deletions docs/contribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Contributing
============

|pyversion| |version| |license| |travis|

All PRs and issues on this project are very welcomed.

If you want to use it, want to talk about the modification about this format or
want to discuss the utility of this format, feel free to open an issue at
http://github.com/j0ack/pybeeryaml/.

All the code contribution must follow the
`PEP8 guide <https://www.python.org/dev/peps/pep-0008/>`_.


.. |pyversion| image:: https://img.shields.io/pypi/pyversions/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |version| image:: https://img.shields.io/pypi/v/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |license| image:: https://img.shields.io/github/license/j0ack/pybeeryaml.svg
:target: https://www.gnu.org/licenses/gpl-3.0.txt
.. |travis| image:: https://img.shields.io/travis/j0ack/pybeeryaml.svg
:target: https://travis-ci.org/j0ack/pybeeryaml
26 changes: 26 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
PyBeerYAML
==========

|pyversion| |version| |license| |travis|

A YAML format parser for beer storage.

Parse a recipe from a YAML file and returns an object containing ingredients and
metadata. Supports export to `beerxml <http://beerxml.com/>`_ format.

.. toctree::
:maxdepth: 1

yaml_format
quickstart
contribute
api/pybeeryaml

.. |pyversion| image:: https://img.shields.io/pypi/pyversions/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |version| image:: https://img.shields.io/pypi/v/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |license| image:: https://img.shields.io/github/license/j0ack/pybeeryaml.svg
:target: https://www.gnu.org/licenses/gpl-3.0.txt
.. |travis| image:: https://img.shields.io/travis/j0ack/pybeeryaml.svg
:target: https://travis-ci.org/j0ack/pybeeryaml
60 changes: 60 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Quick start
===========

|pyversion| |version| |license| |travis|

Installation
------------

.. code:: sh
pip install pybeeryaml
Usage
-----

.. code:: python
from pybeeryaml import Recipe
path_to_beeryaml_file = "/tmp/my_recipe.yml"
# create recipe from file
recipe = Recipe.from_file(path_to_beeryaml_file)
# or from string
with open(path_to_beeryaml_file, "r") as mybeer:
recipe2 = Recipe.from_yaml(mybeer.read())
assert recipe == recipe2 # True
# convert to beerxml format
recipexml = recipe.to_xml()
# create your recipe
recipe = Recipe(
name="Test", brewer="TROUVERIE Joachim", type="Pale Ale",
batch_size=10.0, boil_time=60.0, boil_size=15.0, style="Test"
)
# convert it to yaml
yaml_data = recipe.to_yaml()
Testing
-------

Unit tests can be run with `pytest <https://docs.pytest.org/en/latest/>`_.

.. code:: sh
python -m pytest tests
.. |pyversion| image:: https://img.shields.io/pypi/pyversions/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |version| image:: https://img.shields.io/pypi/v/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |license| image:: https://img.shields.io/github/license/j0ack/pybeeryaml.svg
:target: https://www.gnu.org/licenses/gpl-3.0.txt
.. |travis| image:: https://img.shields.io/travis/j0ack/pybeeryaml.svg
:target: https://travis-ci.org/j0ack/pybeeryaml
70 changes: 70 additions & 0 deletions docs/yaml_format.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Why using YAML to store beer recipes ?
======================================

|pyversion| |version| |license| |travis|

**Why are you using another format since beerxml is widely used ?**

The reason is very simple, `XML <https://en.wikipedia.org/wiki/XML>`_ is very
verbose. Furthermore `beerxml <http://beerxml.com>`_ format is a very complete
data description containing lots of mandatory keys which can be irrelevant for
your recipe. This two formats have their own purpose and are well formatted
markup languages. The goal of this project is not to replace beerxml but to
make it simpler to use in plain text files.

The main purpose of storing recipes in the `YAML <https://en.wikipedia.org/wiki/YAML>`_
format is to make recipes more *human-readable*. It should be really simple to
write your own recipes in a simple format and read it without needing to use an
external software.

What are the differences with the beerxml format ?
--------------------------------------------------

- BeerYAML format shares the mandatory fields for beer items with the beerxml
format.
- Items' version are all set to `1` by default.
- Recipe's style can either be a dict containing all the mandatory keys like in
beerxml format or a simple string.
- Recipe *record sets* are optionnals and will be set empty when exporting to
xml. A minimal recipe can be represented by this yaml

.. code:: yaml
name: Test
brewer: TROUVERIE Joachim
type: Pale Ale
batch_size: 10.0
boil_time: 60.0
boil_size: 15.0
style: Test
- It is possible to define a *record set* name by its YAML key. Thus

.. code:: yaml
mash_steps:
proteic:
step_time: 60
step_temp: 100
type: Infusion
is equal to

.. code:: yaml
mash_steps:
mash_step:
name: proteic
step_time: 60
step_temp: 100
type: Infusion
.. |pyversion| image:: https://img.shields.io/pypi/pyversions/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |version| image:: https://img.shields.io/pypi/v/pybeeryaml.svg
:target: https://pypi.python.org/pypi/pybeeryaml/
.. |license| image:: https://img.shields.io/github/license/j0ack/pybeeryaml.svg
:target: https://www.gnu.org/licenses/gpl-3.0.txt
.. |travis| image:: https://img.shields.io/travis/j0ack/pybeeryaml.svg
:target: https://travis-ci.org/j0ack/pybeeryaml
Loading

0 comments on commit cecb112

Please sign in to comment.