From d55b483327984b3a23ef8612a58a3efa915c71f7 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 15 May 2019 09:23:28 -0500 Subject: [PATCH] Nest tag project output to make sorting look sane The list of projects was sorted by team name, but only the project names were included in the output, causing the list to seem oddly formatted. This adds the team name as its own top level bullet item to each so it is clear on ownership and looks more logically sorted in the list. Change-Id: I0b892379299709fcefae668f811e746a007354e6 Signed-off-by: Sean McGinnis --- doc/source/_exts/tags.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/source/_exts/tags.py b/doc/source/_exts/tags.py index 380ef81c3..1a613003f 100644 --- a/doc/source/_exts/tags.py +++ b/doc/source/_exts/tags.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -"""Show information about tagged projects. -""" +"""Show information about tagged projects.""" + +from collections import defaultdict from docutils import nodes from docutils.parsers import rst @@ -27,8 +28,7 @@ _projects_by_tag = {} class TaggedProjectsDirective(rst.Directive): - """List the projects tagged with the given tag. - """ + """List the projects tagged with the given tag.""" has_content = True @@ -52,14 +52,18 @@ class TaggedProjectsDirective(rst.Directive): source_name, ) else: - for team_name, deliverable in sorted(project_data): + team_deliverables = defaultdict(list) + + for team_name, deliverable in project_data: + team = projects.slugify(team_name) if deliverable is None: - line = '- :ref:`project-%s`' % projects.slugify(team_name) + team_deliverables[team] = [] else: - line = '- %s (:ref:`project-%s`)' % ( - deliverable, - projects.slugify(team_name), - ) + team_deliverables[team].append(deliverable) + + for team in sorted(team_deliverables, key=lambda x: x.lower()): + line = '- :ref:`project-%s` %s' % ( + team, ', '.join(team_deliverables[team])) result.append(line, source_name) # Parse what we have into a new section.