Skip to content

Commit

Permalink
Update docs and add deprecation warnings, update gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
timvink authored Aug 15, 2024
1 parent ba88bee commit 0329d2d
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,3 @@ git push origin <version>
```

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

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/howto/use_jinja2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

```
```
2 changes: 1 addition & 1 deletion docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "."
Expand Down
5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,6 +65,7 @@ markdown_extensions:
- meta
- admonition
- pymdownx.keys
- pymdownx.escapeall
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.snippets
Expand Down
6 changes: 2 additions & 4 deletions mkdocs_table_reader_plugin/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import re
import logging

from mkdocs.plugins import BasePlugin, get_plugin_logger
from mkdocs.config import config_options
Expand Down Expand Up @@ -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',[])}

Expand Down
13 changes: 13 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 0329d2d

Please sign in to comment.