-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional prefix stripping for resulting output
Add an optional parameter that allows stripping a prefix from each line of the resulting output. As the parameter is optional, this is backwards compatible with the existing API. Additionally: * Add tests * Add note to README regarding the new parameter. * Bump version in setup.py * Add CI for GH actions
- Loading branch information
1 parent
ebd61e3
commit 6b28939
Showing
5 changed files
with
123 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "**.md" | ||
pull_request: | ||
paths-ignore: | ||
- "**.md" | ||
|
||
jobs: | ||
ci: | ||
strategy: | ||
matrix: | ||
python_version: | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
- "3.13" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
- run: pip install pytest | ||
- run: python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import pytest | ||
import mkdocs_pluglet_file_include | ||
|
||
|
||
def test_basic_usage(): | ||
assert ( | ||
mkdocs_pluglet_file_include._find_content( | ||
["# ANCHOR: test", "content", "# ANCHOR_END: test"], anchor_id="test" | ||
) | ||
== "content" | ||
) | ||
|
||
|
||
def test_basic_multi_line_usage(): | ||
assert ( | ||
mkdocs_pluglet_file_include._find_content( | ||
["# ANCHOR: test", "content", "more", "# ANCHOR_END: test"], | ||
anchor_id="test", | ||
) | ||
== "content\nmore" | ||
) | ||
|
||
|
||
def test_basic_multi_anchor(): | ||
assert mkdocs_pluglet_file_include._find_content( | ||
[ | ||
"# ANCHOR: test", | ||
"# ANCHOR: another_test", | ||
"content", | ||
"# ANCHOR_END: another_test", | ||
"outside_content", | ||
"# ANCHOR_END: test", | ||
], | ||
anchor_id="test", | ||
) == "\n".join(["content", "outside_content"]) | ||
|
||
|
||
def test_stripping_lines(): | ||
assert ( | ||
mkdocs_pluglet_file_include._find_content( | ||
["# ANCHOR: test", " content", "# ANCHOR_END: test"], | ||
anchor_id="test", | ||
remove_prefix=" ", | ||
) | ||
== "content" | ||
) | ||
|
||
|
||
def test_stripping_mutilple_lines(): | ||
assert mkdocs_pluglet_file_include._find_content( | ||
[ | ||
"# ANCHOR: test", | ||
" indented: yes", | ||
" content: true", | ||
"# ANCHOR_END: test", | ||
], | ||
anchor_id="test", | ||
remove_prefix=" ", | ||
) == "\n".join(["indented: yes", " content: true"]) |