sphinx_gherkindoc package¶
Bring Gherkin Goodness into the Sphinx/reStructuredText (rST) world.
Subpackages¶
Submodules¶
sphinx_gherkindoc.cli module¶
Module for running the tool from the CLI.
- sphinx_gherkindoc.cli.config()[source]¶
Emit a customized version of the sample sphinx config file.
- Return type
None
sphinx_gherkindoc.files module¶
File-related utils used throughout the module.
- class sphinx_gherkindoc.files.DirData(dir_path: pathlib.Path, path_list: List[str], sub_dirs: List[str], files: List[str])[source]¶
Bases:
tuple
Named tuple containing all the modified os.walk parts for a given path.
Create new instance of DirData(dir_path, path_list, sub_dirs, files)
- property dir_path¶
Alias for field number 0
- property files¶
Alias for field number 3
- property path_list¶
Alias for field number 1
- property sub_dirs¶
Alias for field number 2
- sphinx_gherkindoc.files.is_feature_file(filename)[source]¶
Determine if the given filename is a feature file.
- Return type
bool
sphinx_gherkindoc.glossary module¶
Module specific to building the steps glossary.
- class sphinx_gherkindoc.glossary.GlossaryEntry[source]¶
Bases:
object
Track all the different places, and by which spellings, something is used.
- sphinx_gherkindoc.glossary.make_steps_glossary(project_name, group_by=False)[source]¶
Return SphinxWriter containing the step glossary information, if any.
- Return type
Optional
[SphinxWriter
]
sphinx_gherkindoc.utils module¶
Generic utils used throughout the module.
- class sphinx_gherkindoc.utils.SphinxWriter[source]¶
Bases:
object
Easy Sphinx-format file creator.
- add_output(line, line_breaks=1, indent_by=0)[source]¶
Add output to be written to file.
- Parameters
line (
str
) – The line to be writtenline_breaks (
int
) – The number of line breaks to includeindenty_by – The number of spaces to indent the line.
- Return type
None
- create_section(level, section)[source]¶
Create a reST-formatted section header based on the provided level.
- Parameters
level (
int
) – The level depth of the section header (1-10 supported)section (
str
) – The section title
- Return type
None
- sections = ['', '=', '-', '~', '.', '*', '+', '_', '<', '>', '/']¶
- sphinx_gherkindoc.utils.display_name(path, package_name='', dir_display_name_converter=None)[source]¶
Create a human-readable name for a given project.
Determine the display name for a project given a path and (optional) package name. If a display_name.txt file is found, the first line is returned. Otherwise, return a title-cased string from either the base directory or package_name (if provided).
- Parameters
path (
Path
) – Path for searchingpackage_name (
Optional
[str
]) – Sphinx-style, dot-delimited package name (optional)dir_display_name_converter (
Optional
[Callable
]) – A function for converting a dir to a display name.
- Return type
str
- Returns
A display name for the provided path
- sphinx_gherkindoc.utils.get_all_included_scenarios(feature, include_tags=None, exclude_tags=None)[source]¶
Get all scenarios to include in the docs based on the include/exclude tags.
This is designed to match what tests would be run if you ran a test suite with something like this (pytest-bdd format):
-m include_this_tag -m "not exclude_this_tag"
- Parameters
feature (
FeatureClass
) – The feature whose scenarios are to be filtered.include_tags (
Optional
[List
[str
]]) – Tags for which scenarios should be included.exclude_tags (
Optional
[List
[str
]]) – Tags for which scenarios should be excluded.
- Return type
List
[ScenarioClass
]- Returns
All scenarios to include.
- sphinx_gherkindoc.utils.make_flat_name(path_list, filename_root=None, is_dir=False, ext='.rst')[source]¶
Build a flat file name from the provided information.
- Parameters
path_list (
List
[str
]) – Directory hierarchy to flattenfilename_root (
Optional
[str
]) – If provided, the root of the filename to flatten (no extension)is_dir (
bool
) – If True, mark the new filename as a table of contentsext (
Optional
[str
]) – Optional extension for the new file name
- Return type
str
- Returns
A filename containing the full path, separated by periods
- sphinx_gherkindoc.utils.rst_escape(unescaped, slash_escape=False)[source]¶
Escape reST-ful characters to prevent parsing errors.
- Parameters
unescaped (
str
) – A string that potentially contains characters needing escapingslash_escape (
bool
) – if True, escape slashes found inunescaped
- Return type
str
- Returns
A string which has reST-ful characters appropriately escaped
- sphinx_gherkindoc.utils.set_dry_run(value)[source]¶
Set the value for DRY_RUN outside this module.
- Return type
None
sphinx_gherkindoc.writer module¶
Helper functions for writing rST files.
- sphinx_gherkindoc.writer.apply_role(role, content)[source]¶
Wrap the given content string in the given role.
- Return type
str
- sphinx_gherkindoc.writer.feature_to_rst(source_path, root_path, feature_parser='behave', get_url_from_tag=None, get_url_from_step=None, integrate_background=False, background_step_format='{}', raw_descriptions=False, include_tags=None, exclude_tags=None)[source]¶
Return a SphinxWriter containing the rST for the given feature file.
- Return type
Optional
[SphinxWriter
]
- sphinx_gherkindoc.writer.role_name_from(s)[source]¶
Convert a string to a format that can be used as an rST role.
- Return type
str
- sphinx_gherkindoc.writer.toctree(path_list, subdirs, files, maxtocdepth, root_path, dir_display_name_converter=None)[source]¶
Return a SphinxWriter for one level of a directory tree.
Any rST files found at this level will have their content included in the TOC file instead of being referenced. This allows us to put content in the TOC file directly. The rST files that are included are expected to contain proper headers as well as content. If no rST files are included, a header is created using display_name.
- NOTE: If there is more than one rST file present,
the order of their inclusion in the TOC is by filename sort order.
- Return type