Ali-Akber  Saifee avatar Ali-Akber Saifee committed 59763b9 Merge

- new expandsummary feature
-- only implemented summary extraction for jira & bitbucket issue trackers.

Comments (0)

Files changed (1)

issuetracker/sphinxcontrib/issuetracker.py

                      (issue_id, response.getcode()))
             return None
         issue = json.load(response)
-
     return {'closed': issue['status'] not in ('new', 'open'),
-            'uri': BITBUCKET_URL % locals()}
+            'uri': BITBUCKET_URL % locals(),
+            'summary': issue['title']
+            }
 
 def get_debian_issue_information(app, project, issue_id, user = None, password = None, api_url = None):
     import debianbts
 
 def get_jira_code_issue_information(app, project, issue_id, user = None, password = None, api_url = None):
     from xml.etree import cElementTree as etree
-
+    
     issue_uri = JIRA_URL % locals()
     try:
         with closing(urllib.urlopen(issue_uri)) as response:
     link = tree.find("*/item/link").text
     state = tree.find("*/item/resolution")
     summary = tree.find("*/item/title").text
-    return { 'uri':link
-            ,'closed':state is not None and state.text.lower() != "unresolved"}
+    return { 'uri': link
+            ,'closed': state is not None and state.text.lower() != "unresolved"
+            ,'summary': summary
+            }
 
 
 BUILTIN_ISSUE_TRACKERS = {
             parent.replace(node, new_nodes)
 
 
-def make_issue_reference(issue_uri, content_node, is_closed=False):
+def make_issue_reference(app, issue_uri, content_node, is_closed=False, summary = None):
     """
     Create a reference node for the given issue.
 
     if is_closed:
         reference['classes'].append('issue-closed')
     reference['classes'].append('reference-issue')
-    reference.append(content_node)
+    if app.config.issuetracker_expandsummary and summary:
+        reference.append(nodes.Text("%s" % (summary)))
+    else:
+        reference.append(content_node)
     return reference
 
 
             if (not info) or 'uri' not in info:
                 new_node = node[0]
             else:
-                new_node = make_issue_reference(info['uri'], node[0],
-                                                info.get('closed'))
+                new_node = make_issue_reference(app,
+                                                info['uri'], node[0],
+                                                info.get('closed'),
+                                                info.get('summary'))
             node.replace_self(new_node)
 
 
     app.add_config_value('issuetracker_api_url', None, 'env')
     app.add_config_value('issuetracker_user', None, 'env')
     app.add_config_value('issuetracker_password', None, 'env')
+    app.add_config_value('issuetracker_expandsummary', False, 'env')
 
     
     app.connect('builder-inited', add_stylesheet)
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.