Commits

Doug Hellmann committed 5bd7338

trying readthedocs again

Comments (0)

Files changed (3)

docs/en/history.rst

 dev
 
   - Fix problem with space in WORKON_HOME path (:bbissue:`79`).
+  - Add bitbucket directives to the local sphinx config file to avoid
+    the extra build dependency and to try the doc build on readthedocs,
+    again.
 
 2.6.3
 

docs/sphinx/conf.py

 
 # 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.bitbucket' ]
+extensions = [ ]
 
 bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/'
 
 
 # If false, no module index is generated.
 #latex_use_modindex = True
+
+from docutils import nodes, utils
+from docutils.parsers.rst.roles import set_classes
+
+def make_link_node(rawtext, app, type, slug, options):
+    """Create a link to a BitBucket resource.
+
+    :param rawtext: Text being replaced with link node.
+    :param app: Sphinx application context
+    :param type: Link type (issue, changeset, etc.)
+    :param slug: ID of the thing to link to
+    :param options: Options dictionary passed to role func.
+    """
+    # 
+    try:
+        base = app.config.bitbucket_project_url
+        if not base:
+            raise AttributeError
+    except AttributeError, err:
+        raise ValueError('bitbucket_project_url configuration value is not set (%s)' % str(err))
+    #
+    slash = '/' if base[-1] != '/' else ''
+    ref = base + slash + type + '/' + slug + '/'
+    set_classes(options)
+    node = nodes.reference(rawtext, type + ' ' + utils.unescape(slug), refuri=ref,
+                           **options)
+    return node
+    
+
+def bbissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
+    """Link to a BitBucket issue.
+
+    Returns 2 part tuple containing list of nodes to insert into the
+    document and a list of system messages.  Both are allowed to be
+    empty.
+
+    :param name: The role name used in the document.
+    :param rawtext: The entire markup snippet, with role.
+    :param text: The text marked with the role.
+    :param lineno: The line number where rawtext appears in the input.
+    :param inliner: The inliner instance that called us.
+    :param options: Directive options for customization.
+    :param content: The directive content for customization.
+    """
+    try:
+        issue_num = int(text)
+        if issue_num <= 0:
+            raise ValueError
+    except ValueError:
+        msg = inliner.reporter.error(
+            'BitBucket issue number must be a number greater than or equal to 1; '
+            '"%s" is invalid.' % text, line=lineno)
+        prb = inliner.problematic(rawtext, rawtext, msg)
+        return [prb], [msg]
+    app = inliner.document.settings.env.app
+    node = make_link_node(rawtext, app, 'issue', str(issue_num), options)
+    return [node], []
+
+def bbchangeset_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
+    """Link to a BitBucket changeset.
+
+    Returns 2 part tuple containing list of nodes to insert into the
+    document and a list of system messages.  Both are allowed to be
+    empty.
+
+    :param name: The role name used in the document.
+    :param rawtext: The entire markup snippet, with role.
+    :param text: The text marked with the role.
+    :param lineno: The line number where rawtext appears in the input.
+    :param inliner: The inliner instance that called us.
+    :param options: Directive options for customization.
+    :param content: The directive content for customization.
+    """
+    app = inliner.document.settings.env.app
+    node = make_link_node(rawtext, app, 'changeset', text, options)
+    return [node], []
+
+
+def setup(app):
+    """Install the plugin.
+    
+    :param app: Sphinx application context.
+    """
+    app.add_role('bbissue', bbissue_role)
+    app.add_role('bbchangeset', bbchangeset_role)
+    app.add_config_value('bitbucket_project_url', None, 'env')
+    return

docs/sphinx/requirements.txt

+sphinxcontrib-bitbucket
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.