Skip to content

Md utils

make_bullet(value, indents=0)

Return string with 4 spaces per indent, plus -

Source code in automation/utils/md_utils.py
1
2
3
4
def make_bullet(value, indents=0):
    """Return string with 4 spaces per indent, plus `- `"""
    spaces = indents * "    "
    return f"{spaces}- {value}\n"

Make relative within-doc bulleted link for TOC. name

Parameters:

Name Type Description Default
value str

heading name

required
indents int

indent level for heading

0

Returns:

Name Type Description
link str

markdown formatted indented bullet with relative path for table of contents. E.g., - [Heading name](#heading-name)

Source code in automation/utils/md_utils.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def make_link(value: str, indents: int = 0) -> str:
    """Make relative within-doc bulleted link for TOC. [name](#no-spaces)

    Args:
        value (str): heading name
        indents (int): indent level for heading

    Returns:
        link (str): markdown formatted indented bullet with relative path for
            table of contents. E.g., `    - [Heading name](#heading-name)`
    """
    no_spaces = value.lower().replace(" ", "-")
    link = f"[{value}](#{no_spaces})"
    return make_bullet(link, indents)

make_header(value, level=0)

Return string with level+1 * #

Parameters:

Name Type Description Default
value str

heading content

required
level int

heading level. e.g., # Zero, ## One

0
Source code in automation/utils/md_utils.py
23
24
25
26
27
28
29
30
31
def make_header(value: str, level: (int) = 0):
    """Return string with level+1 * `#`

    Args:
        value (str): heading content
        level (int): heading level. e.g., `# Zero`, `## One`
    """
    prefix = level * "#"
    return f"\n#{prefix} {value}\n"