Skip to content

Commit a253d99

Browse files
authored
Merge pull request #76 from timvink/73_filter_tables
Use `pyproject.toml` syntax
2 parents 6fdf150 + cc8cab7 commit a253d99

File tree

14 files changed

+681
-62
lines changed

14 files changed

+681
-62
lines changed

.github/workflows/pythonpublish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727
2828
- name: Make sure unit tests succeed
2929
run: |
30-
pip install -r tests/test_requirements.txt
31-
pip install .
30+
pip install ".[dev]"
3231
pytest
3332
3433
- name: Build

.github/workflows/workflow.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ jobs:
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717

18-
- name: Static code checking with pyflakes
19-
run: |
20-
pip install pyflakes
21-
pyflakes mkdocs_table_reader_plugin
22-
2318
- name: Run unit tests
2419
run: |
25-
pip install -r tests/test_requirements.txt
26-
pip install -e .
20+
pip install ".[dev]"
2721
pytest --cov=mkdocs_table_reader_plugin --cov-report=xml
2822
2923
- name: Upload coverage to Codecov

mkdocs_table_reader_plugin/__init__.py

Whitespace-only changes.

pyproject.toml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
[build-system]
2+
requires = ["setuptools>=70.0", "setuptools-scm>=8.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project.entry-points."mkdocs.plugins"]
6+
"table-reader" = "mkdocs_table_reader_plugin.plugin:TableReaderPlugin"
7+
8+
[project]
9+
name="mkdocs_table_reader_plugin"
10+
keywords = ["mkdocs", "plugin"]
11+
authors = [
12+
{ name = "Tim Vink", email = "vinktim@gmail.com" }
13+
]
14+
license = { text = "MIT" }
15+
16+
description="MkDocs plugin to directly insert tables from files into markdown."
17+
readme = { file = "README.md", content-type = "text/markdown" }
18+
19+
requires-python=">=3.8"
20+
21+
classifiers=[
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3",
25+
"Programming Language :: Python :: 3.8",
26+
"Programming Language :: Python :: 3.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"License :: OSI Approved :: MIT License",
30+
]
31+
32+
dynamic = ["version","dependencies","optional-dependencies"]
33+
34+
[project.urls]
35+
"Homepage" = "https://github.com/timvink/mkdocs-table-reader-plugin"
36+
37+
[tool.setuptools.dynamic]
38+
version = {attr = "mkdocs_table_reader_plugin.__version__"}
39+
40+
dependencies={file = ["requirements.txt"]}
41+
42+
optional-dependencies.dev={file = ["requirements_dev.txt"]}
43+
optional-dependencies.base={file = ["requirements.txt"]}
44+
optional-dependencies.all={file = ["requirements.txt", "requirements_dev.txt"]}
45+
46+
[tool.pytest.ini_options]
47+
markers = [
48+
"integration: marks tests as integration, meaning they use databases (deselect with '-m \"not integration\"')",
49+
"serial",
50+
"no_temp_caching",
51+
]
52+
53+
# https://github.com/charliermarsh/ruff
54+
[tool.ruff]
55+
56+
# Rules to apply
57+
lint.select= ["E", "F", "I", "UP"]
58+
59+
# Exclude rules
60+
lint.ignore = ['D104'
61+
,'D212'
62+
,'D200'
63+
,'D412'
64+
,'E731'
65+
,'E501'
66+
,'E722'
67+
,'D104'
68+
,'E402'
69+
,"UP038" # UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
70+
]
71+
72+
# Exclude files in tests dir
73+
lint.exclude = [
74+
".bzr",
75+
".direnv",
76+
".eggs",
77+
".git",
78+
".hg",
79+
".mypy_cache",
80+
".nox",
81+
".pants.d",
82+
".pytype",
83+
".ruff_cache",
84+
".svn",
85+
".tox",
86+
".venv",
87+
"__pypackages__",
88+
"_build",
89+
"buck-out",
90+
"build",
91+
"dist",
92+
"node_modules",
93+
"venv",
94+
]
95+
96+
# Set line length, keep same as black
97+
line-length = 120
98+
99+
extend-exclude = [
100+
"*.yml",
101+
"*.toml",
102+
"*.md",
103+
".json",
104+
"Makefile",
105+
"*.txt",
106+
]
107+
108+
#supported for python 3.10
109+
target-version = "py310"
110+
111+
# Always autofix
112+
fix = true
113+
114+
[tool.uv]
115+
dev-dependencies = [
116+
"ruff",
117+
]

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mkdocs>=1.0
2+
pandas>=1.1
3+
tabulate>=0.8.7
4+
PyYAML>=5.4.1

tests/test_requirements.txt renamed to requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ xlrd>=1.0.0
66
openpyxl
77
pyarrow
88
# linting
9-
pyflakes
9+
ruff
1010
# documentation
1111
mkdocs-macros-plugin
1212
mkdocs-material

setup.py

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "3.1.0"

mkdocs_table_reader_plugin/markdown.py renamed to src/mkdocs_table_reader_plugin/markdown.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import re
2-
from typing import Dict
3-
import pandas as pd
42
import textwrap
53

4+
import pandas as pd
5+
66

77
def replace_unescaped_pipes(text: str) -> str:
88
"""
@@ -19,7 +19,7 @@ def replace_unescaped_pipes(text: str) -> str:
1919
return re.sub(r"(?<!\\)\|", "\\|", text)
2020

2121

22-
def convert_to_md_table(df: pd.DataFrame, **markdown_kwargs: Dict) -> str:
22+
def convert_to_md_table(df: pd.DataFrame, **markdown_kwargs: dict) -> str:
2323
"""
2424
Convert dataframe to markdown table using tabulate.
2525
"""

mkdocs_table_reader_plugin/plugin.py renamed to src/mkdocs_table_reader_plugin/plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import re
22

3-
from mkdocs.plugins import BasePlugin, get_plugin_logger
43
from mkdocs.config import config_options
54
from mkdocs.exceptions import ConfigurationError
5+
from mkdocs.plugins import BasePlugin, get_plugin_logger
66

7+
from mkdocs_table_reader_plugin.markdown import add_indentation, convert_to_md_table, fix_indentation
8+
from mkdocs_table_reader_plugin.readers import MACROS, READERS
79
from mkdocs_table_reader_plugin.safe_eval import parse_argkwarg
8-
from mkdocs_table_reader_plugin.readers import READERS, MACROS
9-
from mkdocs_table_reader_plugin.markdown import fix_indentation, add_indentation, convert_to_md_table
1010

1111
logger = get_plugin_logger("table-reader")
1212

@@ -138,7 +138,7 @@ def on_page_markdown(self, markdown, page, config, files, **kwargs):
138138
# match group 0: to extract any leading whitespace
139139
# match group 1: to extract the arguments (positional and keywords)
140140
tag_pattern = re.compile(
141-
r"( *)\{\{\s+%s\((.+)\)\s+\}\}" % reader, flags=re.IGNORECASE
141+
r"( *)\{\{\s+%s\((.+)\)\s+\}\}" % reader, flags=re.IGNORECASE # noqa: UP031
142142
)
143143
matches = re.findall(tag_pattern, markdown)
144144

0 commit comments

Comments
 (0)