Git directive¶
Options¶
The repository directive takes these options.
number_of_revisions: positive integer
Set the number of revision to show commit history. Default is 10.
revision: revision string
Set revision string to show particular commit history.
with_ref_url:
Set as a flag to show commit URL on repository hosting service. It supports github and bitbucket.
include_diff:
Set as a flag to show diff text with commit history. The diff text is hidden with initial state. Clicking around commit message shows the diff text.
Top commit history¶
.. git::
:number_of_revisions: 20
:with_ref_url:
:include_diff:
- fix minor typos
by Tetsuya Morimoto at 2016-09-07 18:30:59
2c8a68d86b3fd4a94c26d83a828873aa3c8037a3
diff --git a/docs/_options.rst b/docs/_options.rst index 5d0ff0c..4889ba3 100644 --- a/docs/_options.rst +++ b/docs/_options.rst @@ -1,7 +1,7 @@ Options ------- -Each repository directive take these options. +The repository directive takes these options. - **number_of_revisions**: positive integer diff --git a/docs/git.rst b/docs/git.rst index 5392cde..4ece3a3 100644 --- a/docs/git.rst +++ b/docs/git.rst @@ -29,7 +29,7 @@ Particular commit log :: .. git:: - :revision: 69ef5f984f8564dceea0e90e8d169b1807247d8a + :revision: 33e6b629ed3d6ed63f64136661642f594b1f4d6f :with_ref_url: :include_diff:
- update to use upload_sphinx command for documentation
by Tetsuya Morimoto at 2016-09-06 14:17:56
c56f2bd20a2266320dfcb50a89a120713c6b940c
diff --git a/setup.cfg b/setup.cfg index 917b7a4..31e9f22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,3 +13,6 @@ release = check -r -s register sdist bdist_wheel upload [check] strict = 1 restructuredtext = 1 + +[upload_sphinx] +upload-dir = docs/_build/html
- update documentation link in README
by Tetsuya Morimoto at 2016-09-06 14:17:11
d26ac0cac5c00688c334fdbf5c1dd488ae6ce0a7
diff --git a/README.md b/README.md index 0c7ca58..ce973b7 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Then, repository directives are available as follows. :with_ref_url: :include_diff: -For more information have a look at the documentation. +For more information have a look at [the documentation](https://pythonhosted.org/sphinxcontrib-vcs/). ## Note
- refactoring document layout
by Tetsuya Morimoto at 2016-09-06 14:07:09
8438b91f6c93e0cb250d5977ba999425f5dccf19
diff --git a/docs/_options.rst b/docs/_options.rst new file mode 100644 index 0000000..5d0ff0c --- /dev/null +++ b/docs/_options.rst @@ -0,0 +1,27 @@ +Options +------- + +Each repository directive take these options. + +- **number_of_revisions**: positive integer + + Set the number of revision to show commit history. Default is 10. + +- **revision**: revision string + + Set revision string to show particular commit history. + +- **with_ref_url**: + + Set as a flag to show commit URL on repository hosting service. + It supports github_ and bitbucket_. + +.. _github: https://github.com/ +.. _bitbucket: https://bitbucket.org/ + +- **include_diff**: + + Set as a flag to show diff text with commit history. + The diff text is hidden with initial state. + Clicking around commit message shows the diff text. + diff --git a/docs/conf.py b/docs/conf.py index ed448b0..33518c2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,7 +80,7 @@ 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'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '_*.rst'] # The reST default role (used for this markup: `text`) to use for all # documents. diff --git a/docs/git.rst b/docs/git.rst index be13cb6..5392cde 100644 --- a/docs/git.rst +++ b/docs/git.rst @@ -4,6 +4,8 @@ Git directive .. contents:: contents :local: +.. include:: _options.rst + Top commit history ------------------ diff --git a/docs/index.rst b/docs/index.rst index 72864c1..cba5231 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,6 @@ Contents: .. toctree:: :maxdepth: 2 - options git mercurial diff --git a/docs/mercurial.rst b/docs/mercurial.rst index 7ed67e2..6c277d4 100644 --- a/docs/mercurial.rst +++ b/docs/mercurial.rst @@ -8,6 +8,8 @@ Mercurial directive .. contents:: contents :local: +.. include:: _options.rst + Top commit history ------------------ diff --git a/docs/options.rst b/docs/options.rst deleted file mode 100644 index 1d61b3a..0000000 --- a/docs/options.rst +++ /dev/null @@ -1,27 +0,0 @@ -Common options --------------- - -Each repository directive take these options. - -- **number_of_revisions**: positive integer - - Set the number of revision to show commit history. Default is 10. - -- **revision**: revision string - - Set revision string to show particular commit history. - -- **with_ref_url**: - - Set as a flag to show commit URL on repository hosting service. - It supports github_ and bitbucket_. - -.. _github: https://github.com/ -.. _bitbucket: https://bitbucket.org/ - -- **include_diff**: - - Set as a flag to show diff text with commit history. - The diff text is hidden with initial state. - Clicking around commit message shows the diff text. -
- add CHANGELOG
by Tetsuya Morimoto at 2016-09-06 11:04:50
244c96329af23583c717e81d5966c431a1dfd1f0
diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6c3c0c1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ + +## ChangeLog + +### 0.1.0 (2016-09-06) + +* first release diff --git a/setup.py b/setup.py index bbf739e..c14fe38 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ requires = [ ] if sys.version_info < (3, 0): - requires.append('Mercurial==3.8.2') + requires.append('Mercurial') setup(
- support to make commit url when the repository was cloned via https
by Tetsuya Morimoto at 2016-09-06 10:53:28
4ad1cc83983fa49b92701a13470433dfc591f3db
diff --git a/sphinxcontrib/repository/_git.py b/sphinxcontrib/repository/_git.py index 8ed8026..8d26616 100644 --- a/sphinxcontrib/repository/_git.py +++ b/sphinxcontrib/repository/_git.py @@ -14,7 +14,10 @@ class GitRepository(Repo): EMPTY_TREE_SHA = '4b825dc642cb6eb9a060e54bf8d69288fbee4904' URL_PATTERN = re.compile( - r'git@.*?:(?P<account>.*?)/(?P<repository_name>.*?)\.git', + r""" + git@.*?:(?P<account>.*?)/(?P<repository_name>.*?)\.git + |https://github.com/(?P<account_>.*?)/(?P<repository_name_>.*?)\.git + """, re.VERBOSE ) def __init__(self, max_count, *args, **kwargs): diff --git a/sphinxcontrib/repository/_mercurial.py b/sphinxcontrib/repository/_mercurial.py index ff6da6e..15da53b 100644 --- a/sphinxcontrib/repository/_mercurial.py +++ b/sphinxcontrib/repository/_mercurial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import +import os import re try: @@ -18,7 +19,10 @@ class MercurialRepository(object): LOG_PATTERN = re.compile(r'(?P<type>\w+):[\t\s]+(?P<value>.*)') URL_PATTERN = re.compile( - r'ssh://hg@bitbucket.org/(?P<account>.*?)/(?P<repository_name>.*?)$' + r""" + ssh://hg@bitbucket.org/(?P<account>.*?)/(?P<repository_name>.*?)$ + |https://.+?@bitbucket.org/(?P<account_>.*?)/(?P<repository_name_>.*?)$ + """, re.VERBOSE ) def __init__(self, limit, path): @@ -27,21 +31,17 @@ class MercurialRepository(object): self.raw = hg.repository(self.ui, path=path) self._changeset = {} self._commits = [] - self.set_default_path() - - def set_default_path(self): - self.ui.pushbuffer() - commands.paths(self.ui, self.raw, search='default') - lines = self.ui.popbuffer().decode('utf-8').split('\n') - if len(lines) > 0: - _path = lines[0] - if _path.split('/')[-1] == '...': - # FIXME: how to get repository name - repository_name = self.raw.root.split('/')[-1] - _path = _path.replace('...', repository_name) - self.default_path = _path - else: - self.default_path = '' + self.set_default_path(path) + + def set_default_path(self, path): + # FIXME: how to get default path + # for some reason, commands.paths() doesn't return default path + self.default_path = '' + with open(os.path.join(path, '.hg', 'hgrc')) as f: + for line in f: + if line.startswith('default'): + self.default_path = line.split('=')[1].strip() + break def read_changeset_lines(self, lines): is_found, commit = False, {} diff --git a/sphinxcontrib/repository/utils.py b/sphinxcontrib/repository/utils.py index 53fa542..95c205b 100644 --- a/sphinxcontrib/repository/utils.py +++ b/sphinxcontrib/repository/utils.py @@ -37,7 +37,7 @@ def find_repository_top(current_dir, conf_dir): return None if os.path.exists(repository_dir) and os.path.isdir(repository_dir): - return current_dir + return os.path.abspath(current_dir) else: parent_dir = os.path.join(current_dir, os.path.pardir) return find_repository_top(parent_dir, conf_dir) @@ -49,9 +49,11 @@ def make_commit_url(pattern, path, site, revision): return '' info = m.groupdict() + account = info.get('account') or info.get('account_') + repository = info.get('repository_name') or info.get('repository_name_') return site['commit_template'].format( site=site['site'], - user=info['account'], - repository=info['repository_name'], + user=account, + repository=repository, sha=revision, )
- add documentation
by Tetsuya Morimoto at 2016-09-06 09:54:43
ef9050583198b9d429a67a30387f01f698ca01df
diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..a4e1519 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,225 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help +help: + @echo "Please use \`make <target>' where <target> is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " epub3 to make an epub3" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + @echo " dummy to check syntax errors of document sources" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: dirhtml +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +.PHONY: singlehtml +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +.PHONY: pickle +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +.PHONY: json +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +.PHONY: htmlhelp +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +.PHONY: qthelp +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sphinxcontrib-vcs.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sphinxcontrib-vcs.qhc" + +.PHONY: applehelp +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +.PHONY: devhelp +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/sphinxcontrib-vcs" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sphinxcontrib-vcs" + @echo "# devhelp" + +.PHONY: epub +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +.PHONY: epub3 +epub3: + $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 + @echo + @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." + +.PHONY: latex +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: latexpdfja +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: text +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +.PHONY: man +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +.PHONY: texinfo +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +.PHONY: info +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +.PHONY: changes +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +.PHONY: linkcheck +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +.PHONY: doctest +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +.PHONY: coverage +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +.PHONY: xml +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +.PHONY: pseudoxml +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +.PHONY: dummy +dummy: + $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy + @echo + @echo "Build finished. Dummy builder generates no files." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..ed448b0 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,338 @@ +# -*- coding: utf-8 -*- +# +# sphinxcontrib-vcs documentation build configuration file, created by +# sphinx-quickstart on Tue Sep 6 08:30:32 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 os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- 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 = ['sphinxcontrib.vcs'] + +# 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 encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'sphinxcontrib-vcs' +copyright = u'2016, Tetsuya Morimoto' +author = u'Tetsuya Morimoto' + +# 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 = u'0.1' +# The full version, including alpha/beta/rc tags. +release = u'0.1' + +# 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 + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# 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 reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# 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 = 'nature' + +# 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 themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. +# "<project> v<release> documentation" by default. +# +# html_title = u'sphinxcontrib-vcs v0.1' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# 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'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'sphinxcontrib-vcsdoc' + +# -- 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, 'sphinxcontrib-vcs.tex', u'sphinxcontrib-vcs Documentation', + u'Tetsuya Morimoto', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- 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, 'sphinxcontrib-vcs', u'sphinxcontrib-vcs Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- 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, 'sphinxcontrib-vcs', u'sphinxcontrib-vcs Documentation', + author, 'sphinxcontrib-vcs', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False diff --git a/docs/git.rst b/docs/git.rst new file mode 100644 index 0000000..be13cb6 --- /dev/null +++ b/docs/git.rst @@ -0,0 +1,39 @@ +Git directive +============= + +.. contents:: contents + :local: + +Top commit history +------------------ + +:: + + .. git:: + :number_of_revisions: 20 + :with_ref_url: + :include_diff: + + +.. git:: + :number_of_revisions: 20 + :with_ref_url: + :include_diff: + + +Particular commit log +--------------------- + +:: + + .. git:: + :revision: 69ef5f984f8564dceea0e90e8d169b1807247d8a + :with_ref_url: + :include_diff: + + +.. git:: + :revision: 33e6b629ed3d6ed63f64136661642f594b1f4d6f + :with_ref_url: + :include_diff: + diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..72864c1 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,33 @@ +.. sphinxcontrib-vcs documentation master file, created by + sphinx-quickstart on Tue Sep 6 08:30:32 2016. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to sphinxcontrib-vcs's documentation! +============================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + options + git + mercurial + + +Acknowledgments +--------------- + +`sphinxcontrib-vcs` is inspired from the sphinx-git_. + +.. _sphinx-git: https://github.com/OddBloke/sphinx-git + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..d4b88a6 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,281 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^<target^>` where ^<target^> is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. epub3 to make an epub3 + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + echo. coverage to run coverage check of the documentation if enabled + echo. dummy to check syntax errors of document sources + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +REM Check if sphinx-build is available and fallback to Python version if any +%SPHINXBUILD% 1>NUL 2>NUL +if errorlevel 9009 goto sphinx_python +goto sphinx_ok + +:sphinx_python + +set SPHINXBUILD=python -m sphinx.__init__ +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +:sphinx_ok + + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\sphinxcontrib-vcs.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\sphinxcontrib-vcs.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "epub3" ( + %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "coverage" ( + %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage + if errorlevel 1 exit /b 1 + echo. + echo.Testing of coverage in the sources finished, look at the ^ +results in %BUILDDIR%/coverage/python.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +if "%1" == "dummy" ( + %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. Dummy builder generates no files. + goto end +) + +:end diff --git a/docs/mercurial.rst b/docs/mercurial.rst new file mode 100644 index 0000000..7ed67e2 --- /dev/null +++ b/docs/mercurial.rst @@ -0,0 +1,31 @@ +Mercurial directive +=================== + +.. note:: + + supports Python 2.7 only + +.. contents:: contents + :local: + +Top commit history +------------------ + +:: + + .. mercurial:: + :number_of_revisions: 20 + :with_ref_url: + :include_diff: + + +Particular commit log +--------------------- + +:: + + .. mercurial:: + :revision: 33:g87922kd38d8 + :with_ref_url: + :include_diff: + diff --git a/docs/options.rst b/docs/options.rst new file mode 100644 index 0000000..1d61b3a --- /dev/null +++ b/docs/options.rst @@ -0,0 +1,27 @@ +Common options +-------------- + +Each repository directive take these options. + +- **number_of_revisions**: positive integer + + Set the number of revision to show commit history. Default is 10. + +- **revision**: revision string + + Set revision string to show particular commit history. + +- **with_ref_url**: + + Set as a flag to show commit URL on repository hosting service. + It supports github_ and bitbucket_. + +.. _github: https://github.com/ +.. _bitbucket: https://bitbucket.org/ + +- **include_diff**: + + Set as a flag to show diff text with commit history. + The diff text is hidden with initial state. + Clicking around commit message shows the diff text. +
- update README
by Tetsuya Morimoto at 2016-09-06 09:51:25
fdf96ea293f5feb7d3fc40c39bc1d551a0ada0f8
diff --git a/README.md b/README.md index e13ad3a..0c7ca58 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,45 @@ -# Sphinxcontrib-vcs +# sphinxcontrib-vcs [![Build Status](https://travis-ci.org/t2y/sphinxcontrib-vcs.svg?branch=master)](https://travis-ci.org/t2y/sphinxcontrib-vcs/) + +*sphinxcontrib-vcs* provides showing commit history in version control system. + +## Setup + + $ pip install sphinxcontrib-vcs + +## Usage + +Add *'sphinxcontrib.vcs'* as extensions into conf.py. + + $ vi conf.py + extensions = ['sphinxcontrib.vcs'] + +Then, repository directives are available as follows. + +### Git + + .. git:: + :number_of_revisions: 20 + :with_ref_url: + :include_diff: + + +### Mercurial + + .. mercurial:: + :number_of_revisions: 20 + :with_ref_url: + :include_diff: + +For more information have a look at the documentation. + +## Note + +[Mercurial](https://www.mercurial-scm.org/) supports Python 2.x only. +So *sphinxcontrib-vcs* supports the *mercurial* directive on Python 2.7. + +## Acknowledgments + +*sphinxcontrib-vcs* is inspired from the [sphinx-git](https://github.com/OddBloke/sphinx-git). +
- update travis settings
by Tetsuya Morimoto at 2016-09-06 07:11:23
3abf43ed00702d2aa4fdac3720b98b3647ee01e6
diff --git a/.travis.yml b/.travis.yml index 38379a1..bc36e79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,6 @@ env: - TOXENV=py27 - TOXENV=py33 - TOXENV=py34 - - TOXENV=py35 - - TOXENV=coverage install: pip install docutils tox script: tox
- add build status
by Tetsuya Morimoto at 2016-09-06 07:08:50
2e34c4b691c0e101433ad0bc75550073c72707c6
diff --git a/README.md b/README.md index b6f2af0..e13ad3a 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # Sphinxcontrib-vcs + +[![Build Status](https://travis-ci.org/t2y/sphinxcontrib-vcs.svg?branch=master)](https://travis-ci.org/t2y/sphinxcontrib-vcs/)
- add .travis.yml
by Tetsuya Morimoto at 2016-09-06 07:02:26
69ef5f984f8564dceea0e90e8d169b1807247d8a
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..38379a1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: python +python: 2.7 +env: + matrix: + - TOXENV=py27 + - TOXENV=py33 + - TOXENV=py34 + - TOXENV=py35 + - TOXENV=coverage + +install: pip install docutils tox +script: tox
- update packaging information
by Tetsuya Morimoto at 2016-09-06 07:01:31
878536aa9060a505915c123d624ec3e4994c2ef3
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..979b448 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +License for sphinxcontrib-vcs +============================= + +Copyright (c) 2016 by Tetsuya MORIMOTO +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..cf3d2cd --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include MANIFEST.in +include LICENSE +include README.md +include CHANGELOG.md +recursive-include sphinxcontrib/_static *.html *.css *.js +recursive-include tests *.py *.rst diff --git a/setup.py b/setup.py index 604bb82..bbf739e 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( long_description=long_description, classifiers=[ 'License :: OSI Approved :: BSD License', - 'Development Status :: 3 - Alpha', + 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2',
- add some tests using sphinx-testing
by Tetsuya Morimoto at 2016-09-06 06:37:30
2171def33cdb40ce9d3d47eb8d03b4c6e37e1404
diff --git a/setup.py b/setup.py index e67a045..604bb82 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except (IOError, ImportError): version_py = open('sphinxcontrib/vcs.py').read() metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", version_py)) -description='Sphinx extension to show commit history in version control system' +desc = 'Sphinx extension to show commit history in version control system' requires = [ 'GitPython', @@ -31,7 +31,7 @@ if sys.version_info < (3, 0): setup( name='sphinxcontrib-vcs', version=metadata['version'], - description=description, + description=desc, long_description=long_description, classifiers=[ 'License :: OSI Approved :: BSD License', @@ -62,5 +62,7 @@ setup( namespace_packages=['sphinxcontrib'], include_package_data=True, install_requires=requires, - tests_require=['tox', 'pytest', 'pytest-pep8', 'pytest-flakes'], + tests_require=[ + 'flake8', 'mock', 'nose', 'reportlab', 'sphinx-testing', + ], ) diff --git a/tests/docs/basic/conf.py b/tests/docs/basic/conf.py new file mode 100644 index 0000000..c538d5c --- /dev/null +++ b/tests/docs/basic/conf.py @@ -0,0 +1,339 @@ +# -*- coding: utf-8 -*- +# +# Test documentation build configuration file, created by +# sphinx-quickstart on Fri Sep 2 17:47:39 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 os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- 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 = ['sphinxcontrib.vcs'] + +# 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 encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Test' +copyright = u'2016, Tetsuya Morimoto' +author = u'Tetsuya Morimoto' + +# 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 = u'0.1' +# The full version, including alpha/beta/rc tags. +release = u'0.1' + +# 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 = 'ja' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# 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 = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# 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 themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. +# "<project> v<release> documentation" by default. +# +# html_title = u'Test v0.3' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. +# This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# 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'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Testdoc' + +# -- 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, 'Test.tex', u'Test Documentation', + u'Tetsuya Morimoto', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- 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, 'test', u'Test Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- 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, 'Test', u'Test Documentation', + author, 'Test', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False diff --git a/tests/docs/basic/index.rst b/tests/docs/basic/index.rst new file mode 100644 index 0000000..3c34f2b --- /dev/null +++ b/tests/docs/basic/index.rst @@ -0,0 +1,8 @@ +Welcome to Test's documentation! +================================ + +.. git:: + :number_of_revisions: 5 + :with_ref_url: + :include_diff: + diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..0bba91e --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from sphinx_testing import with_app + + +@with_app(buildername='html', srcdir='tests/docs/basic/') +def test_build_html(app, status, warning): + app.builder.build_all() + + +@with_app(buildername='singlehtml', srcdir='tests/docs/basic/') +def test_build_singlehtml(app, status, warning): + app.builder.build_all() + + +@with_app(buildername='latex', srcdir='tests/docs/basic/') +def test_build_latex(app, status, warning): + app.builder.build_all() + + +@with_app(buildername='epub', srcdir='tests/docs/basic/') +def test_build_epub(app, status, warning): + app.builder.build_all() + + +@with_app(buildername='json', srcdir='tests/docs/basic/') +def test_build_json(app, status, warning): + app.builder.build_all() diff --git a/tests/test_errors.py b/tests/test_errors.py new file mode 100644 index 0000000..f24fa05 --- /dev/null +++ b/tests/test_errors.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +import unittest + +from sphinx_testing import with_app + + +class TestSphinxcontribVcsErrors(unittest.TestCase): + @with_app(srcdir='tests/docs/basic', write_docstring=True) + def test_no_revision_error(self, app, status, warning): + """ + .. git:: + :revision: + """ + app.builder.build_all() + message = 'revision string required as argument.' + self.assertIn(message, warning.getvalue()) diff --git a/tox.ini b/tox.ini index 2b56de3..952ad09 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,16 @@ [tox] envlist = py27, py33, py34, py35 -indexserver = - pypi = https://pypi.python.org/simple [testenv] -deps = - :pypi:pytest - :pypi:pytest-pep8 - :pypi:pytest-flakes - -commands = py.test -v --pep8 --flakes sphinxcontrib +passenv = + LANG + LC_ALL +deps= + nose + mock + flake8 + reportlab + sphinx-testing +commands= + nosetests -v + flake8 setup.py sphinxcontrib/ tests/
- add css/js to toggle showing diff text
by Tetsuya Morimoto at 2016-09-05 20:30:59
14490da1f9acb2ba2a343b42b041e8e288916b69
diff --git a/sphinxcontrib/_static/contrib-vcs.css b/sphinxcontrib/_static/contrib-vcs.css new file mode 100644 index 0000000..71cb66d --- /dev/null +++ b/sphinxcontrib/_static/contrib-vcs.css @@ -0,0 +1,13 @@ +/* sphinxcontrib-vcs style */ + +.contrib-vcs-message { + cursor: pointer; +} + +.toggle-open { + display: inline; +} + +.toggle-close { + display: none; +} diff --git a/sphinxcontrib/_static/contrib-vcs.js b/sphinxcontrib/_static/contrib-vcs.js new file mode 100644 index 0000000..c2ff723 --- /dev/null +++ b/sphinxcontrib/_static/contrib-vcs.js @@ -0,0 +1,32 @@ +function toggleDiff(event) { + 'use strict'; + + /* requires element.classList */ + var i, sha, elements, elem; + + sha = event.target.id; + elements = document.getElementsByClassName('contrib-vcs-diff'); + for (i = 0; i < elements.length; i += 1) { + elem = elements[i]; + if (elem.id === sha) { + elem.classList.toggle('toggle-open'); + elem.classList.toggle('toggle-close'); + break; + } + } +} + +function addToggleDiffEvent() { + 'use strict'; + + var i, elements = document.getElementsByClassName('contrib-vcs-message'); + for (i = 0; i < elements.length; i += 1) { + elements[i].addEventListener('click', toggleDiff, false); + } +} + +$(document).ready(function () { + 'use strict'; + + addToggleDiffEvent(); +}); diff --git a/sphinxcontrib/vcs.py b/sphinxcontrib/vcs.py index de0ca75..a95a0ba 100644 --- a/sphinxcontrib/vcs.py +++ b/sphinxcontrib/vcs.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- +import os from datetime import datetime import six from docutils import nodes from docutils.parsers.rst import Directive from docutils.parsers.rst import directives +from sphinx.util.osutil import copyfile from .repository import GitRepository from .repository import MercurialRepository @@ -12,11 +14,11 @@ from .repository import find_repository_top __version__ = '0.1.0' - -OPTION_INCLUDE_DIFF = 'include_diff' -OPTION_NUMBER_OF_REVISIONS = 'number_of_revisions' -OPTION_REVISION = 'revision' -OPTION_WITH_REF_URL = 'with_ref_url' +CSS_CLASS = { + 'diff': ['contrib-vcs-diff', 'toggle-close'], + 'directive': ['contrib-vcs'], + 'message': ['contrib-vcs-message'], +} def get_revision(argument): @@ -25,9 +27,13 @@ def get_revision(argument): return argument.strip() -class BaseDirective(Directive): +OPTION_INCLUDE_DIFF = 'include_diff' +OPTION_NUMBER_OF_REVISIONS = 'number_of_revisions' +OPTION_REVISION = 'revision' +OPTION_WITH_REF_URL = 'with_ref_url' - TARGET_ID = 'vcs' + +class BaseDirective(Directive): option_spec = { OPTION_INCLUDE_DIFF: directives.flag, @@ -36,6 +42,16 @@ class BaseDirective(Directive): OPTION_WITH_REF_URL: directives.flag, } + def _make_message_node(self, message, sha): + message, classes = six.text_type(message), [] + if OPTION_INCLUDE_DIFF in self.options: + classes = CSS_CLASS['message'] + return nodes.strong(ids=[sha], text=message, classes=classes) + + def _make_diff_node(self, diff, sha): + classes = CSS_CLASS['diff'] + return nodes.literal_block(ids=[sha], text=diff, classes=classes) + def run(self): list_node = nodes.bullet_list() @@ -44,12 +60,11 @@ class BaseDirective(Directive): if repo is None: return - targetnode = nodes.target('', '', ids=[self.TARGET_ID]) revision = self.options.get(OPTION_REVISION) for commit in repo.get_commits(revision=revision): item = self.get_changelog(repo, commit) list_node.append(item) - return targetnode + [list_node] + return [list_node] class GitDirective(BaseDirective): @@ -62,7 +77,8 @@ class GitDirective(BaseDirective): def get_changelog(self, repo, commit): item = nodes.list_item() - item.append(nodes.strong(text=six.text_type(commit.message))) + + item.append(self._make_message_node(commit.message, commit.hexsha)) item.append(nodes.inline(text=six.text_type(' by '))) item.append(nodes.emphasis(text=six.text_type(commit.author.name))) item.append(nodes.inline(text=six.text_type(' at '))) @@ -77,7 +93,7 @@ class GitDirective(BaseDirective): if OPTION_INCLUDE_DIFF in self.options: diff = repo.get_diff(commit.hexsha) - item.append(nodes.literal_block(text=six.text_type(diff))) + item.append(self._make_diff_node(diff, commit.hexsha)) return item @@ -93,7 +109,8 @@ class MercurialDirective(BaseDirective): def get_changelog(self, repo, commit): item = nodes.list_item() - item.append(nodes.strong(text=six.text_type(commit['summary']))) + + item.append(self._make_message_node(commit['summary'], commit['sha'])) item.append(nodes.inline(text=six.text_type(' by '))) item.append(nodes.emphasis(text=six.text_type(commit['user']))) item.append(nodes.inline(text=six.text_type(' at '))) @@ -106,15 +123,48 @@ class MercurialDirective(BaseDirective): if OPTION_INCLUDE_DIFF in self.options: diff = repo.get_diff(commit['revision']) - item.append(nodes.literal_block(text=six.text_type(diff))) + item.append(self._make_diff_node(diff, commit['sha'])) return item +CSS_FILES = ['contrib-vcs.css'] +JS_FILES = ['contrib-vcs.js'] + + +def add_assets(app): + for file_ in CSS_FILES: + app.add_stylesheet(file_) + for file_ in JS_FILES: + app.add_javascript(file_) + + +def copy_assets(app, exception): + if app.builder.name != 'html' or exception: + return + + if len(app.builder.config.html_static_path) <= 0: + return + + current_path = os.path.abspath(os.path.dirname(__file__)) + static_path = app.builder.config.html_static_path[0] + + app.info('Copying vcs stylesheet/javascript... ', nonl=True) + for file_ in CSS_FILES + JS_FILES: + dest = os.path.join(app.builder.outdir, static_path, file_) + source = os.path.join(current_path, static_path, file_) + copyfile(source, dest) + app.info('done') + + def setup(app): app.add_directive('git', GitDirective) app.add_directive('mercurial', MercurialDirective) + # copying css/js to _static + app.connect('builder-inited', add_assets) + app.connect('build-finished', copy_assets) + return { 'version': __version__, 'parallel_read_safe': True,
- update package information
by Tetsuya Morimoto at 2016-09-05 20:29:13
9e023d257fa06d70deb58c03c0ca07a7bc89e575
diff --git a/setup.py b/setup.py index 361785c..e67a045 100644 --- a/setup.py +++ b/setup.py @@ -7,12 +7,12 @@ from setuptools import find_packages, setup try: import pypandoc - LONG_DESCRIPTION = '\n'.join([ + long_description = '\n'.join([ pypandoc.convert('README.md', 'rst'), pypandoc.convert('CHANGELOG.md', 'rst'), ]) except (IOError, ImportError): - LONG_DESCRIPTION = '' + long_description = '' version_py = open('sphinxcontrib/vcs.py').read() metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", version_py)) @@ -32,7 +32,7 @@ setup( name='sphinxcontrib-vcs', version=metadata['version'], description=description, - long_description=LONG_DESCRIPTION, + long_description=long_description, classifiers=[ 'License :: OSI Approved :: BSD License', 'Development Status :: 3 - Alpha', @@ -52,7 +52,7 @@ setup( 'Topic :: Documentation :: Sphinx', 'Topic :: Utilities', ], - url='https://github.com/t2y/...', + url='https://github.com/t2y/sphinxcontrib-vcs', license='BSD', author='Tetsuya Morimoto', author_email='tetsuya dot morimoto at gmail dot com',
- update package description
by Tetsuya Morimoto at 2016-09-05 13:40:47
c2f6d18503f408179a4942329b810ca00e5280e7
diff --git a/setup.py b/setup.py index a0d8085..361785c 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ except (IOError, ImportError): version_py = open('sphinxcontrib/vcs.py').read() metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", version_py)) +description='Sphinx extension to show commit history in version control system' requires = [ 'GitPython', @@ -30,7 +31,7 @@ if sys.version_info < (3, 0): setup( name='sphinxcontrib-vcs', version=metadata['version'], - description='Sphinx extension to show Changelog in version control system', + description=description, long_description=LONG_DESCRIPTION, classifiers=[ 'License :: OSI Approved :: BSD License',
- support ‘revision’ option to filter arbitrary revision commit for mercurial repository
by Tetsuya Morimoto at 2016-09-05 13:26:59
36f50ab100ea99a737013b50a5387988676f1da0
diff --git a/sphinxcontrib/repository/_mercurial.py b/sphinxcontrib/repository/_mercurial.py index d411329..ff6da6e 100644 --- a/sphinxcontrib/repository/_mercurial.py +++ b/sphinxcontrib/repository/_mercurial.py @@ -5,6 +5,7 @@ import re try: from mercurial import ui, hg, commands + from mercurial.error import RepoLookupError except ImportError: pass @@ -62,7 +63,28 @@ class MercurialRepository(object): commit[type_] = value return index, commit - def get_commits(self, limit=None): + def get_commit(self, revision): + self.ui.pushbuffer() + try: + commands.log(self.ui, self.raw, rev=[str(revision)]) + except RepoLookupError as err: + log.error(err) + log.warn("Not found '%s' in mercurial repository" % revision) + else: + lines = self.ui.popbuffer().decode('utf-8').split('\n') + index, commit = self.read_changeset_lines(lines) + changeset = commit.get('changeset') + if changeset is not None: + self._commits.append(commit) + self._changeset[changeset] = commit + return commit + + def get_commits(self, revision=None, limit=None): + if revision is not None: + self.get_commit(revision) + self.limit = 1 + return self._commits[:self.limit] + if len(self._commits) == 0 or limit is not None: self._commits[:] = [] if limit is not None:
- add ‘revision’ option to filter arbitrary revision commit for git repository
by Tetsuya Morimoto at 2016-09-05 13:02:14
ef3ff726b95c46adb9a644dc4ac2a707ee62a0f1
diff --git a/sphinxcontrib/repository/_git.py b/sphinxcontrib/repository/_git.py index cbdff7d..8ed8026 100644 --- a/sphinxcontrib/repository/_git.py +++ b/sphinxcontrib/repository/_git.py @@ -3,9 +3,11 @@ from __future__ import absolute_import import re +import gitdb from git import Repo from .utils import find_hosting_site, make_commit_url +from .utils import log class GitRepository(Repo): @@ -25,7 +27,27 @@ class GitRepository(Repo): def branch_name(self): return self.head.ref.name - def get_commits(self, max_count=None, **kwargs): + def get_commit(self, revision): + try: + commit = self.commit(revision) + except gitdb.exc.BadName as err: + log.error(err) + log.warn("Not found '%s' in git repository" % revision) + else: + self._commits.append(commit) + self._hexsha[commit.hexsha] = 0 + if commit.parents: + prev_commit = commit.parents[0] + self._commits.append(prev_commit) + self._hexsha[prev_commit.hexsha] = 1 + return commit + + def get_commits(self, revision=None, max_count=None, **kwargs): + if revision is not None: + self.get_commit(revision) + self.max_count = 1 + return self._commits[:self.max_count] + if len(self._commits) == 0 or max_count is not None: self._hexsha.clear() self._commits[:] = [] diff --git a/sphinxcontrib/vcs.py b/sphinxcontrib/vcs.py index 7326fc9..de0ca75 100644 --- a/sphinxcontrib/vcs.py +++ b/sphinxcontrib/vcs.py @@ -15,9 +15,16 @@ __version__ = '0.1.0' OPTION_INCLUDE_DIFF = 'include_diff' OPTION_NUMBER_OF_REVISIONS = 'number_of_revisions' +OPTION_REVISION = 'revision' OPTION_WITH_REF_URL = 'with_ref_url' +def get_revision(argument): + if argument is None: + raise ValueError('revision string required as argument') + return argument.strip() + + class BaseDirective(Directive): TARGET_ID = 'vcs' @@ -25,6 +32,7 @@ class BaseDirective(Directive): option_spec = { OPTION_INCLUDE_DIFF: directives.flag, OPTION_NUMBER_OF_REVISIONS: directives.positive_int, + OPTION_REVISION: get_revision, OPTION_WITH_REF_URL: directives.flag, } @@ -37,7 +45,8 @@ class BaseDirective(Directive): return targetnode = nodes.target('', '', ids=[self.TARGET_ID]) - for commit in repo.get_commits(): + revision = self.options.get(OPTION_REVISION) + for commit in repo.get_commits(revision=revision): item = self.get_changelog(repo, commit) list_node.append(item) return targetnode + [list_node]
- refactoring to move log utility function
by Tetsuya Morimoto at 2016-09-05 11:49:44
4b4991eb2cdc49cc2912a84ae1c944f48a004a2b
diff --git a/sphinxcontrib/repository/_mercurial.py b/sphinxcontrib/repository/_mercurial.py index 2b0f5bb..d411329 100644 --- a/sphinxcontrib/repository/_mercurial.py +++ b/sphinxcontrib/repository/_mercurial.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import -import logging import re try: @@ -10,14 +9,9 @@ except ImportError: pass from .utils import find_hosting_site, find_repository_top +from .utils import log from .utils import make_commit_url -logging.basicConfig( - format='%(asctime)s %(name)s %(levelname)s %(message)s', - level=logging.INFO, -) -log = logging.getLogger('sphinxcontrib-vcs') - class MercurialRepository(object): diff --git a/sphinxcontrib/repository/utils.py b/sphinxcontrib/repository/utils.py index cd7fc18..53fa542 100644 --- a/sphinxcontrib/repository/utils.py +++ b/sphinxcontrib/repository/utils.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import +import logging import os import re @@ -15,6 +16,12 @@ HOSTING_SERVICE = { }, } +logging.basicConfig( + format='%(asctime)s %(name)s %(levelname)s %(message)s', + level=logging.INFO, +) +log = logging.getLogger('sphinxcontrib-vcs') + def find_hosting_site(url): if url.find('github.com') > 0:
- refactoring to use defined directives options
by Tetsuya Morimoto at 2016-09-05 11:45:34
69822ee79d627c278cdfd4f0bb7ec321a78f71a5
diff --git a/sphinxcontrib/vcs.py b/sphinxcontrib/vcs.py index de3fc38..7326fc9 100644 --- a/sphinxcontrib/vcs.py +++ b/sphinxcontrib/vcs.py @@ -4,6 +4,7 @@ from datetime import datetime import six from docutils import nodes from docutils.parsers.rst import Directive +from docutils.parsers.rst import directives from .repository import GitRepository from .repository import MercurialRepository @@ -12,20 +13,25 @@ from .repository import find_repository_top __version__ = '0.1.0' +OPTION_INCLUDE_DIFF = 'include_diff' +OPTION_NUMBER_OF_REVISIONS = 'number_of_revisions' +OPTION_WITH_REF_URL = 'with_ref_url' + + class BaseDirective(Directive): TARGET_ID = 'vcs' option_spec = { - 'include_diff': bool, - 'number_of_revisions': int, - 'with_ref_url': bool, + OPTION_INCLUDE_DIFF: directives.flag, + OPTION_NUMBER_OF_REVISIONS: directives.positive_int, + OPTION_WITH_REF_URL: directives.flag, } def run(self): list_node = nodes.bullet_list() - number_of_revisions = self.options.get('number_of_revisions', 10) + number_of_revisions = self.options.get(OPTION_NUMBER_OF_REVISIONS, 10) repo = self.get_repo(number_of_revisions) if repo is None: return @@ -55,12 +61,12 @@ class GitDirective(BaseDirective): commit_date = datetime.fromtimestamp(commit.authored_date) item.append(nodes.emphasis(text=six.text_type(commit_date))) - if self.options.get('with_ref_url') is not None: + if OPTION_WITH_REF_URL in self.options: ref_url = repo.get_commit_url(commit.hexsha) ref = nodes.reference('', commit.hexsha, refuri=ref_url) item.append(nodes.paragraph('', '', ref)) - if self.options.get('include_diff') is not None: + if OPTION_INCLUDE_DIFF in self.options: diff = repo.get_diff(commit.hexsha) item.append(nodes.literal_block(text=six.text_type(diff))) @@ -84,12 +90,12 @@ class MercurialDirective(BaseDirective): item.append(nodes.inline(text=six.text_type(' at '))) item.append(nodes.emphasis(text=six.text_type(commit['date']))) - if self.options.get('with_ref_url') is not None: + if OPTION_WITH_REF_URL in self.options: ref_url = repo.get_commit_url(commit['sha']) ref = nodes.reference('', commit['sha'], refuri=ref_url) item.append(nodes.paragraph('', '', ref)) - if self.options.get('include_diff') is not None: + if OPTION_INCLUDE_DIFF in self.options: diff = repo.get_diff(commit['revision']) item.append(nodes.literal_block(text=six.text_type(diff)))
Particular commit log¶
.. git::
:revision: 33e6b629ed3d6ed63f64136661642f594b1f4d6f
:with_ref_url:
:include_diff:
- initial commit
by Tetsuya Morimoto at 2016-09-02 23:14:28
33e6b629ed3d6ed63f64136661642f594b1f4d6f
diff --git a/README.md b/README.md new file mode 100644 index 0000000..b6f2af0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Sphinxcontrib-vcs