diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index eeacead..0d541d3 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -20,4 +20,4 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Codespell - uses: codespell-project/actions-codespell@v2 + uses: codespell-project/actions-codespell@v4 diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 779c45c..347a153 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -13,10 +13,10 @@ jobs: id-token: write contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 196c7e3..5d7c7ce 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -28,7 +28,7 @@ jobs: - name: Upload coverage to Codecov if: contains(env.USING_COVERAGE, matrix.python-version) && github.ref == 'refs/heads/master' - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0df8ded..fd6e4a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,17 +50,3 @@ git push origin ``` Then manually create a github release to trigger publishing to pypi. - - -TODO: - -Changes: - -- `macros` should now be defined _before_ `table-reader` (previously after) -- table-reader will now always search docs_dir _and_ config_dir to find a table file. (deprecated option..) - - -Upgrading guide - -- Remove `base_path` and `search_page_directory` options from the config - diff --git a/README.md b/README.md index 93ec330..e31dd8a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ In your markdown files you can now use: Where the path is relative to the location of your project's `mkdocs.yml` file, _or_ your project's `docs/` directory, _or_ the location of your markdown source file (all 3 possible locations will be searched, in that order). -- There are [readers](https://timvink.github.io/mkdocs-table-reader-plugin/readers/) for `.csv`, `.fwf`, `.json`, `.xlsx`, `.yaml` and `.tsv` files. There is also the `read_raw()` reader that will allow you to insert tables (or other content) already in markdown format. +- There are [readers](https://timvink.github.io/mkdocs-table-reader-plugin/readers/) for `.csv`, `.fwf`, `.json`, `.xls`, `.xlsx`, `.yaml`, `.feather` and `.tsv` files. There is also the `read_raw()` reader that will allow you to insert tables (or other content) already in markdown format. +- `table-reader` is compatible with [`mkdocs-macros-plugin`](https://mkdocs-macros-plugin.readthedocs.io/en/latest/), which means you can [dynamically insert tables using jinja2 syntax](https://timvink.github.io/mkdocs-table-reader-plugin/howto/use_jinja2/). ## Documentation and how-to guides diff --git a/docs/howto/use_jinja2.md b/docs/howto/use_jinja2.md index 662a956..38ccaa2 100644 --- a/docs/howto/use_jinja2.md +++ b/docs/howto/use_jinja2.md @@ -19,8 +19,8 @@ Now you can do cool things like dynamically load a list of tables: {% set table_names = ["basic_table.csv","basic_table2.csv"] %} {% for table_name in table_names %} -{{ read_csv(table_name) }} +{ { read_csv(table_name) }} {% endfor %} -``` \ No newline at end of file +``` diff --git a/docs/schema.json b/docs/schema.json index b738606..f7a6a55 100644 --- a/docs/schema.json +++ b/docs/schema.json @@ -14,7 +14,7 @@ "type": "object", "properties": { "data_path": { - "title": "The path to your table files should be relative to the base_path. If you use a folder for all your table files you can shorten the path specification by setting the data_path.", + "title": "Additional path to search", "markdownDescription": "https://timvink.github.io/mkdocs-table-reader-plugin/options/#data_path", "type": "string", "default": "." diff --git a/mkdocs.yml b/mkdocs.yml index 51414a1..4240b3c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -51,8 +51,8 @@ plugins: - table-reader: data_path: "docs/assets" - git-authors: - exclude: - - index.md + exclude: + - index.md - git-revision-date-localized: type: timeago timezone: Europe/Amsterdam @@ -65,6 +65,7 @@ markdown_extensions: - meta - admonition - pymdownx.keys + - pymdownx.escapeall - pymdownx.highlight - pymdownx.inlinehilite - pymdownx.snippets diff --git a/mkdocs_table_reader_plugin/plugin.py b/mkdocs_table_reader_plugin/plugin.py index 01e6f0a..2c958a6 100644 --- a/mkdocs_table_reader_plugin/plugin.py +++ b/mkdocs_table_reader_plugin/plugin.py @@ -1,6 +1,4 @@ -import os import re -import logging from mkdocs.plugins import BasePlugin, get_plugin_logger from mkdocs.config import config_options @@ -32,9 +30,9 @@ def on_config(self, config, **kwargs): Config """ if "search_page_directory" in self.config: - logger.warning(f"[table-reader]: The 'search_page_directory' configuration option is deprecated, it will always be searched. Please remove it from your mkdocs.yml.") + logger.warning("[table-reader]: The 'search_page_directory' configuration option is deprecated, it will always be searched. Please remove it from your mkdocs.yml.") if "base_path" in self.config: - logger.warning(f"[table-reader]: The 'base_path' configuration option is deprecated. Both the config_dir and docs_dir will be searched. Please remove it from your mkdocs.yml.") + logger.warning("[table-reader]: The 'base_path' configuration option is deprecated. Both the config_dir and docs_dir will be searched. Please remove it from your mkdocs.yml.") self.readers = {reader: READERS[reader].set_config_context(mkdocs_config=config, plugin_config=self.config) for reader in self.config.get('select_readers') if reader in self.config.get('select_readers',[])} diff --git a/tests/test_build.py b/tests/test_build.py index 88fcd37..46d50a7 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -374,3 +374,16 @@ def test_csv_with_no_string_headers(tmp_path): page_with_tag = tmp_proj / "site/index.html" contents = page_with_tag.read_text() assert re.search(r"4242", contents) + +def test_macros_jinja2_syntax(tmp_path): + tmp_proj = setup_clean_mkdocs_folder( + "tests/fixtures/jinja/mkdocs.yml", tmp_path + ) + result = build_docs_setup(tmp_proj) + assert result.exit_code == 0, "'mkdocs build' command failed" + + # Make sure the file.csv is inserted + page_with_tag = tmp_proj / "site/index.html" + contents = page_with_tag.read_text() + assert re.search(r"531456", contents) +