1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 # This program and the accompanying materials are made available under the
5 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 # and is available at http://www.eclipse.org/legal/epl-v10.html
9 Embeds a simple table with issues.
13 from docutils import nodes
14 from docutils.parsers.rst import directives, Directive
19 __copyright__ = "Copyright(c) 2021 PANTHEON.tech, s.r.o."
20 __license__ = "Eclipse Public License v1.0"
22 class JiraFixedIssuesDirective(Directive):
24 JIRA Fixed Issues directive
27 required_arguments = 0
28 optional_arguments = 0
31 "project": directives.unchanged_required,
32 "versions": directives.unchanged_required,
36 jira = JIRA(server="https://jira.opendaylight.org")
37 prj = jira.project(self.options.get('project'))
38 (from_ver, to_ver) = self.options.get('versions').split('-', 1)
41 for ver in jira.project_versions(prj):
42 if ver.name >= from_ver and ver.name <= to_ver:
43 versions.add(ver.name)
44 versions = ", ".join(versions)
46 # FIXME: this is not quite nice: can we emit the table markup directly
48 '.. list-table:: Issues resolved in versions %s through %s' % (from_ver, to_ver),
49 # FIXME: bind to https://datatables.net/
61 issues = jira.search_issues('project = %s AND resolution is not EMPTY AND fixVersion in (%s) ORDER BY type ASC' % (prj, versions))
65 for version in issue.fields.fixVersions:
66 fixVersions.add(version.name)
67 fixVersions = list(fixVersions)
70 table.append(' * - .. image:: %s' % issue.fields.issuetype.iconUrl)
71 table.append(' :align: center')
72 table.append(' :alt: %s' % issue.fields.issuetype.name)
73 table.append(' - `%s <https://jira.opendaylight.org/browse/%s>`_' % (issue.key, issue.key))
74 table.append(' - %s' % issue.fields.summary)
75 table.append(' - %s' % issue.fields.resolution)
76 table.append(' - %s' % ", ".join(fixVersions))
80 for idx, line in enumerate(table):
81 self.content.data.insert(idx, line)
82 self.content.items.insert(idx, (None, idx))
84 node = nodes.container()
85 self.state.nested_parse(self.content, self.content_offset, node)
88 class JiraKnownIssuesDirective(Directive):
90 JIRA Known Issues directive
93 required_arguments = 0
94 optional_arguments = 0
97 "project": directives.unchanged_required,
98 "versions": directives.unchanged_required,
102 jira = JIRA(server="https://jira.opendaylight.org")
103 prj = jira.project(self.options.get('project'))
104 (from_ver, to_ver) = self.options.get('versions').split('-', 1)
107 for ver in jira.project_versions(prj):
108 if ver.name >= from_ver and ver.name <= to_ver:
109 versions.add(ver.name)
110 versions = ", ".join(versions)
112 # FIXME: this is not quite nice: can we emit the table markup directly
114 '.. list-table:: Issues affecting versions %s through %s' % (from_ver, to_ver),
115 # FIXME: bind to https://datatables.net/
116 ' :class: datatable',
124 ' - Affected Version(s)',
128 issues = jira.search_issues('project = %s AND affectedVersion in (%s) AND fixVersion NOT in (%s) ORDER BY type ASC' % (prj, versions, versions))
132 for version in issue.fields.fixVersions:
133 fixVersions.add(version.name)
134 fixVersions = list(fixVersions)
137 # Groom affectedVersions
138 affectedVersions = set()
139 for version in issue.fields.versions:
140 affectedVersions.add(version.name)
141 affectedVersions = list(affectedVersions)
142 affectedVersions.sort()
144 table.append(' * - .. image:: %s' % issue.fields.issuetype.iconUrl)
145 table.append(' :align: center')
146 table.append(' :alt: %s' % issue.fields.issuetype.name)
147 table.append(' - `%s <https://jira.opendaylight.org/browse/%s>`_' % (issue.key, issue.key))
148 table.append(' - %s' % issue.fields.summary)
149 table.append(' - %s' % issue.fields.status)
150 table.append(' - %s' % ", ".join(affectedVersions))
151 table.append(' - %s' % ", ".join(fixVersions))
155 for idx, line in enumerate(table):
156 self.content.data.insert(idx, line)
157 self.content.items.insert(idx, (None, idx))
159 node = nodes.container()
160 self.state.nested_parse(self.content, self.content_offset, node)
165 :type app: sphinx.application.Sphinx
167 app.add_directive('jira_fixed_issues', JiraFixedIssuesDirective)
168 app.add_directive('jira_known_issues', JiraKnownIssuesDirective)
172 'parallel_read_safe': True,
173 'parallel_write_safe': True,