-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tag glossary #59
base: master
Are you sure you want to change the base?
Tag glossary #59
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "sphinx_gherkindoc" | ||
version = "3.6.4" | ||
version = "3.6.5" | ||
description = "A tool to convert Gherkin into Sphinx documentation" | ||
authors = ["Lewis Franklin <[email protected]>", "Doug Philips <[email protected]>"] | ||
readme = "README.rst" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Module specific functions for tag management and document building.""" | ||
from .utils import SphinxWriter | ||
from typing import Set, Optional | ||
from functools import reduce | ||
|
||
|
||
tag_set: Set[str] = set() | ||
|
||
|
||
def make_tag_list(project_name: str) -> Optional[SphinxWriter]: | ||
"""Make caller to finalize a tag list.""" | ||
if not tag_set: | ||
return None | ||
tag_list_sphinx_doc = SphinxWriter() | ||
tag_list_sphinx_doc = tag_list_preamble(tag_list_sphinx_doc, project_name) | ||
tag_list_sphinx_doc = reduce( | ||
lambda acc, t: add_tag(acc, t), sorted(tag_set), tag_list_sphinx_doc | ||
) | ||
return tag_list_sphinx_doc | ||
|
||
|
||
def tag_list_preamble(sphinx_dox: SphinxWriter, project_name: str) -> SphinxWriter: | ||
"""Add a preamble to the tag list.""" | ||
sphinx_dox.create_section(1, f"{project_name} Tag List") | ||
return sphinx_dox | ||
|
||
|
||
def add_tag(sphinx_dox: SphinxWriter, tag: str) -> SphinxWriter: | ||
"""Map function over tag list.""" | ||
sphinx_dox.add_output(f"* {tag}") | ||
sphinx_dox.blank_line() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why the extra blank line (it's more apparent in the test code that the unnumbered list has the extra line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be the pattern in other places where we build sphinx documents. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, ok then, you can just use the |
||
return sphinx_dox |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Tests for tag list.""" | ||
import pytest | ||
import copy | ||
from sphinx_gherkindoc import tag_management | ||
|
||
|
||
@pytest.fixture() | ||
def tag_list(): | ||
old_value = copy.deepcopy(tag_management.tag_set) | ||
tag_management.tag_set = {"Tag1", "Tag2", "Tag3"} | ||
yield | ||
tag_management.tag_set = old_value | ||
|
||
|
||
def test_tag_list_output(tag_list): | ||
tag_list_output = [ | ||
"Test Tag List\n", | ||
"=============\n\n", | ||
"* Tag1\n", | ||
"\n", | ||
"* Tag2\n", | ||
"\n", | ||
"* Tag3\n", | ||
"\n", | ||
] | ||
assert tag_list_output == tag_management.make_tag_list("Test")._output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code block looks like it was copied from the glossary block right above it.
Being that the previous block has 'return' statements in it, the code might never get to this block.
And if another block is added after this one, a return here might prevent the code from getting to that.
This means restructuring the two blocks. My initial feeling is that this function is already too big :-) but that is a pre-existing condition for this change. I think in the interests of simplicity, I'm willing to leave this as is unless you want to undertake refactoring the glossary and this new tags into helper functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at this moment @dgou 😆