Skip to content

Commit

Permalink
SYN
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-shawley committed Jun 18, 2016
0 parents commit d3d8829
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/
dist/
env/
*.egg-info/
__pycache__/
*.pyc
25 changes: 25 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Sphinx JSON Domain
==================
I was surprised that this didn't already exist somewhere when I wanted to
describe a JSON document outside of using `sphinxcontrib-httpdomain`_ to
document one of my APIs. This extension simplifies describing structured
JSON documents using a new `Sphinx domain`_.

.. code-block:: rst
.. json:object:: Github User
What Github's API thinks a user looks like.
:property string login: the user's login
:property integer id: Github assigned unique user identifier
:property string avatar_url: url to user's selected avatar image
or the empty string
:property string gravatar_url: url to the user's gravatar image
or the empty string
This will format to something pretty and make references to
`:json:object:`Github User`` work as expected.

.. _sphinxcontrib-httpdomain: https://pythonhosted.org/sphinxcontrib-httpdomain/
.. _sphinx domain: http://www.sphinx-doc.org/en/stable/domains.html#what-is-a-domain
1 change: 1 addition & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1.logo {font-size: 14pt}
29 changes: 29 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import alabaster
from sphinxcontrib import jsondomain


project = 'sphinx-jsondomain'
copyright = '2016, Dave Shawley'
release = '.'.join(str(v) for v in jsondomain.version_info[:2])
version = jsondomain.__version__
needs_sphinx = '1.0'
extensions = [
'sphinx.ext.intersphinx',
]

master_doc = 'index'
html_theme = 'alabaster'
html_static_path = ['_static']
html_theme_path = [alabaster.get_path()]
html_sidebars = {
'**': ['about.html',
'navigation.html'],
}
html_theme_options = {
'description': 'Describe JSON documents',
'github_user': 'dave-shawley',
'github_repo': 'sphinx-jsondomain',
}
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
19 changes: 19 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Contributing
============

Setting up your environment
---------------------------
First of all, build yourself a nice clean virtual environment using the
:mod:`venv` module (or `virtualenv`_ if you must). Then pull in the
requirements::

sphinx-jsondomain$ python3 -mvenv env
sphinx-jsondomain$ env/bin/pip install -qr requires/development.txt

Giving it Back
--------------
Once you have something substantial that you would like to contribute back
to the extension, push your branch up to github.com and issue a Pull Request
against the main repository.

.. _virtualenv: https://virtualenv.pypa.io/en/stable/
7 changes: 7 additions & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Release History
===============

`Next Release`_
---------------

.. _Next Release: https://github.com/dave-shawley/sphinx-jsondomain/compare/0.0.0...HEAD
7 changes: 7 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. include:: ../README.rst

.. toctree::
:hidden:

contributing
history
2 changes: 2 additions & 0 deletions requires/development.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r installation.txt
wheel
1 change: 1 addition & 0 deletions requires/installation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sphinx>=1.4,<2
46 changes: 46 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python

import os.path

import setuptools

from sphinxcontrib import jsondomain


def read_requirements(name):
requirements = []
with open(os.path.join('requires', name)) as req_file:
for line in req_file:
if '#' in line:
line = line[:line.index('#')]
line = line.strip()
if line.startswith('-r'):
requirements.extend(read_requirements(line[2:].strip()))
elif line and not line.startswith('-'):
requirements.append(line)
return requirements


setuptools.setup(
name='sphinx-jsondomain',
version=jsondomain.__version__,
url='https://github.com/dave-shawley/sphinx-jsondomain',
description='Describe JSON document structures in sphinx',
long_description='\n'+open('README.rst').read(),
author='Dave Shawley',
author_email='daveshawley+python@gmail.com',
packages=setuptools.find_packages(),
namespace_packages=['sphinxcontrib'],
install_requires=read_requirements('installation.txt'),
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Framework :: Sphinx :: Extension',
],
)
2 changes: 2 additions & 0 deletions sphinxcontrib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__import__('pkg_resources').declare_namespace(__name__)

2 changes: 2 additions & 0 deletions sphinxcontrib/jsondomain/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version_info = (0, 0, 0)
__version__ = '.'.join(str(c) for c in version_info)

0 comments on commit d3d8829

Please sign in to comment.