Skip to content

Commit 5bd7338

Browse files
committed
trying readthedocs again
1 parent eafcb10 commit 5bd7338

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

docs/en/history.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Release History
55
dev
66

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

912
2.6.3
1013

docs/sphinx/conf.py

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Add any Sphinx extension module names here, as strings. They can be extensions
2626
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
27-
extensions = [ 'sphinxcontrib.bitbucket' ]
27+
extensions = [ ]
2828

2929
bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/'
3030

@@ -196,3 +196,90 @@
196196

197197
# If false, no module index is generated.
198198
#latex_use_modindex = True
199+
200+
from docutils import nodes, utils
201+
from docutils.parsers.rst.roles import set_classes
202+
203+
def make_link_node(rawtext, app, type, slug, options):
204+
"""Create a link to a BitBucket resource.
205+
206+
:param rawtext: Text being replaced with link node.
207+
:param app: Sphinx application context
208+
:param type: Link type (issue, changeset, etc.)
209+
:param slug: ID of the thing to link to
210+
:param options: Options dictionary passed to role func.
211+
"""
212+
#
213+
try:
214+
base = app.config.bitbucket_project_url
215+
if not base:
216+
raise AttributeError
217+
except AttributeError, err:
218+
raise ValueError('bitbucket_project_url configuration value is not set (%s)' % str(err))
219+
#
220+
slash = '/' if base[-1] != '/' else ''
221+
ref = base + slash + type + '/' + slug + '/'
222+
set_classes(options)
223+
node = nodes.reference(rawtext, type + ' ' + utils.unescape(slug), refuri=ref,
224+
**options)
225+
return node
226+
227+
228+
def bbissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
229+
"""Link to a BitBucket issue.
230+
231+
Returns 2 part tuple containing list of nodes to insert into the
232+
document and a list of system messages. Both are allowed to be
233+
empty.
234+
235+
:param name: The role name used in the document.
236+
:param rawtext: The entire markup snippet, with role.
237+
:param text: The text marked with the role.
238+
:param lineno: The line number where rawtext appears in the input.
239+
:param inliner: The inliner instance that called us.
240+
:param options: Directive options for customization.
241+
:param content: The directive content for customization.
242+
"""
243+
try:
244+
issue_num = int(text)
245+
if issue_num <= 0:
246+
raise ValueError
247+
except ValueError:
248+
msg = inliner.reporter.error(
249+
'BitBucket issue number must be a number greater than or equal to 1; '
250+
'"%s" is invalid.' % text, line=lineno)
251+
prb = inliner.problematic(rawtext, rawtext, msg)
252+
return [prb], [msg]
253+
app = inliner.document.settings.env.app
254+
node = make_link_node(rawtext, app, 'issue', str(issue_num), options)
255+
return [node], []
256+
257+
def bbchangeset_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
258+
"""Link to a BitBucket changeset.
259+
260+
Returns 2 part tuple containing list of nodes to insert into the
261+
document and a list of system messages. Both are allowed to be
262+
empty.
263+
264+
:param name: The role name used in the document.
265+
:param rawtext: The entire markup snippet, with role.
266+
:param text: The text marked with the role.
267+
:param lineno: The line number where rawtext appears in the input.
268+
:param inliner: The inliner instance that called us.
269+
:param options: Directive options for customization.
270+
:param content: The directive content for customization.
271+
"""
272+
app = inliner.document.settings.env.app
273+
node = make_link_node(rawtext, app, 'changeset', text, options)
274+
return [node], []
275+
276+
277+
def setup(app):
278+
"""Install the plugin.
279+
280+
:param app: Sphinx application context.
281+
"""
282+
app.add_role('bbissue', bbissue_role)
283+
app.add_role('bbchangeset', bbchangeset_role)
284+
app.add_config_value('bitbucket_project_url', None, 'env')
285+
return

docs/sphinx/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sphinxcontrib-bitbucket

0 commit comments

Comments
 (0)