Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 2 additions & 75 deletions .github/workflows/nox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
matrix:
include:
- session: test
python-versions: "3.8, 3.9, 3.10, 3.11, 3.12, 3.13"
other-args: "-p 3.8 3.9 3.10 3.11 3.12 3.13"
python-versions: "3.9, 3.10, 3.11, 3.12, 3.13"
other-args: ""
codecov: true
packages: ""

Expand Down Expand Up @@ -79,76 +79,3 @@ jobs:
working-directory: antsibull-docs-parser
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
nox-test-37:
# python3.7 is not available on ubuntu-latest
runs-on: ubuntu-22.04
name: "Run nox test session (Python 3.7)"
defaults:
run:
working-directory: antsibull-docs-parser
steps:
- name: Check out antsibull-docs-parser
uses: actions/checkout@v4
with:
path: antsibull-docs-parser
persist-credentials: false
- name: Setup nox
uses: wntrblm/[email protected]
with:
python-versions: "3.7"
- name: Set up nox environments
run: |
nox -v -e "test" -p 3.7 --install-only
nox -v -e coverage --install-only
- name: "Run nox -e test -p 3.7"
run: |
nox -v -e "test" -p 3.7 --reuse-existing-virtualenvs --no-install
- name: Report coverage
run: |
nox -v -e coverage --reuse-existing-virtualenvs --no-install
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
name: "test"
working-directory: antsibull-docs-parser
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
nox-test-36:
# python3.6 is not available on ubuntu-latest
runs-on: ubuntu-20.04
name: "Run nox test session (Python 3.6)"
defaults:
run:
working-directory: antsibull-docs-parser
steps:
- name: Check out antsibull-docs-parser
uses: actions/checkout@v4
with:
path: antsibull-docs-parser
persist-credentials: false
- name: Setup nox
uses: wntrblm/[email protected] # DO NOT UPDATE THIS! Newer versions do not work with Python 3.6
with:
python-versions: "3.6"
# https://github.com/ansible-community/antsibull-docs-parser/issues/25
# Newer virtualenv versions seem to cause failures with Python 3.6
- name: Setup nox - downgrade virtualenv
run: |
pipx inject --force nox 'virtualenv<20.22.0'
- name: Set up nox environments
run: |
nox -v -e test -p 3.6 --install-only
nox -v -e coverage --install-only
- name: Run unit tests
run: |
nox -v -e test -p 3.6 --reuse-existing-virtualenvs --no-install
- name: Report coverage
run: |
nox -v -e coverage --reuse-existing-virtualenvs --no-install
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
name: nox-test-36
working-directory: antsibull-docs-parser
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions changelogs/fragments/68-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
removed_features:
- "antsibull-docs-parser no longer supports Python 3.6, 3.7, and 3.8. Python 3.9+ is now required (https://github.com/ansible-community/antsibull-docs-parser/pull/68)."
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def install(session: nox.Session, *args, editable=False, **kwargs):
session.install(*args, "-U", **kwargs)


@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"])
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
def test(session: nox.Session):
install(session, ".[test, coverage]", editable=True)
covfile = Path(session.create_tmp(), ".coverage")
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name = "antsibull-docs-parser"
dynamic = ["version"]
description = "Python library for processing Ansible documentation markup"
readme = "README.md"
requires-python = ">=3.6.1"
requires-python = ">=3.9"
license = "GPL-3.0-or-later AND BSD-2-Clause"
license-files.globs = ["LICENSES/*.txt"]
authors = [
Expand All @@ -22,13 +22,10 @@ maintainers = [
{ name = "Maxwell G", email = "[email protected]" },
]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 5 - Production/Stable",
"Framework :: Ansible",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
2 changes: 2 additions & 0 deletions src/antsibull_docs_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Library for processing Ansible documentation markup.
"""

from __future__ import annotations

__version__ = "1.1.1.post0"

__all__ = ("__version__",)
13 changes: 7 additions & 6 deletions src/antsibull_docs_parser/_parser_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
Internal parsing code.
"""

from __future__ import annotations

import re
import typing as t

_ESCAPE_OR_COMMA = re.compile(r"\\(.)| *(,) *")
_ESCAPE_OR_CLOSING = re.compile(r"\\(.)|([)])")
Expand All @@ -19,12 +20,12 @@ def parse_parameters_escaped(
index: int,
parameter_count: int,
strict: bool,
) -> t.Tuple[t.List[str], int, t.Optional[str]]:
result: t.List[str] = []
) -> tuple[list[str], int, str | None]:
result: list[str] = []
parameters_left = parameter_count
while parameters_left > 1:
parameters_left -= 1
value: t.List[str] = []
value: list[str] = []
while True:
match = _ESCAPE_OR_COMMA.search(text, pos=index)
if not match:
Expand Down Expand Up @@ -77,8 +78,8 @@ def parse_parameters_unescaped(
index: int,
parameter_count: int,
strict: bool, # pylint: disable=unused-argument
) -> t.Tuple[t.List[str], int, t.Optional[str]]:
result: t.List[str] = []
) -> tuple[list[str], int, str | None]:
result: list[str] = []
first = True
parameters_left = parameter_count
while parameters_left > 1:
Expand Down
18 changes: 9 additions & 9 deletions src/antsibull_docs_parser/ansible_doc_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Ansible-doc text serialization.
"""

from __future__ import annotations

import typing as t

from . import dom
Expand All @@ -17,7 +19,7 @@
class AnsibleDocTextFormatter(Formatter):
@staticmethod
def _format_option_like(
part: t.Union[dom.OptionNamePart, dom.ReturnValuePart],
part: dom.OptionNamePart | dom.ReturnValuePart,
) -> str:
value = part.value
if value is None:
Expand Down Expand Up @@ -54,7 +56,7 @@ def format_italic(self, part: dom.ItalicPart) -> str:
def format_link(self, part: dom.LinkPart) -> str:
return f"{part.text} <{part.url}>"

def format_module(self, part: dom.ModulePart, url: t.Optional[str]) -> str:
def format_module(self, part: dom.ModulePart, url: str | None) -> str:
return f"[{part.fqcn}]"

def format_rst_ref(self, part: dom.RSTRefPart) -> str:
Expand All @@ -69,18 +71,16 @@ def format_text(self, part: dom.TextPart) -> str:
def format_env_variable(self, part: dom.EnvVariablePart) -> str:
return f"`{part.name}'"

def format_option_name(self, part: dom.OptionNamePart, url: t.Optional[str]) -> str:
def format_option_name(self, part: dom.OptionNamePart, url: str | None) -> str:
return self._format_option_like(part)

def format_option_value(self, part: dom.OptionValuePart) -> str:
return f"`{part.value}'"

def format_plugin(self, part: dom.PluginPart, url: t.Optional[str]) -> str:
def format_plugin(self, part: dom.PluginPart, url: str | None) -> str:
return f"[{part.plugin.fqcn}]"

def format_return_value(
self, part: dom.ReturnValuePart, url: t.Optional[str]
) -> str:
def format_return_value(self, part: dom.ReturnValuePart, url: str | None) -> str:
return self._format_option_like(part)


Expand All @@ -90,12 +90,12 @@ def format_return_value(
def to_ansible_doc_text(
paragraphs: t.Sequence[dom.Paragraph],
formatter: Formatter = DEFAULT_ANSIBLE_DOC_FORMATTER,
link_provider: t.Optional[LinkProvider] = None,
link_provider: LinkProvider | None = None,
par_start: str = "",
par_end: str = "",
par_sep: str = "\n\n",
par_empty: str = "",
current_plugin: t.Optional[dom.PluginIdentifier] = None,
current_plugin: dom.PluginIdentifier | None = None,
) -> str:
return _format_paragraphs(
paragraphs,
Expand Down
Loading