Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rendering for submodules #40

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ underscore)::

extensions = ['sphinx_git']

There is one global switch that changes the behavior of sphinx-git when
processing git submodules. Default behavior is that sphing-git renders
the git history of the sphinx directory. If you want sphinx-git to
render the history of the submodule instead you can add::

git_respect_submodules = True

Add A git Changelog To Your Project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -58,4 +65,4 @@ was compiled with the ``git_commit_detail`` directive::

.. git_commit_detail::
:branch:
:commit:
:commit:
10 changes: 7 additions & 3 deletions sphinx_git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
from docutils.parsers.rst import directives
from git import Repo
from sphinx.util.compat import Directive

from os import path

# pylint: disable=too-few-public-methods, abstract-method
class GitDirectiveBase(Directive):
def _find_repo(self):
env = self.state.document.settings.env
repo = Repo(env.srcdir, search_parent_directories=True)
return repo
if env.config.git_respect_submodules:
srcdir = path.dirname(env.doc2path(env.docname, base=True))
else:
srcdir = env.srcdir
return Repo(srcdir, search_parent_directories=True)


# pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -195,3 +198,4 @@ def _build_markup(self, commits):
def setup(app):
app.add_directive('git_changelog', GitChangelog)
app.add_directive('git_commit_detail', GitCommitDetail)
app.add_config_value('git_respect_submodules', False, 'env')