Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore) lock update and update in CICD #35

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
cheap_checks:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Python setup
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand All @@ -39,7 +39,7 @@ jobs:
- name: Black
run: poetry run python -m black . --check --diff
- name: ruff
run: poetry run ruff .
run: poetry run ruff check .
- name: isort
run: poetry run isort . --check

Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
# Initial Setup
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Documentation setup
- name: Setup Quarto
Expand All @@ -63,7 +63,7 @@ jobs:
run: quarto --version

# Python setup
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: View Python --version
Expand All @@ -88,7 +88,7 @@ jobs:
- name: mkdocs
run: poetry run python -m mkdocs build --strict

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
verbose: true # optional (default = false)

Expand All @@ -98,9 +98,9 @@ jobs:
needs: ci
if: endsWith(github.ref, 'heads/release') && (github.event_name == 'push')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')

# Documentation setup
Expand All @@ -110,7 +110,7 @@ jobs:
run: quarto --version

# Python setup
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: View Python --version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Black
uses: psf/black@stable
- name: Set up Python environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ repos:
exclude: "(.*tests/data/.*/.*.md)"
- id: debug-statements
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
rev: v3.17.0
hooks:
- id: pyupgrade
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
- repo: https://github.com/psf/black
rev: 24.4.0
rev: 24.8.0
hooks:
- id: black
language_version: python3.8
language_version: python3.9
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.7
rev: v0.6.3
hooks:
- id: ruff
- repo: https://github.com/pycqa/pydocstyle
Expand Down
42 changes: 26 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
toc-title: Table of contents
---

![Pypi
version](https://img.shields.io/pypi/v/mkquartodocs?style=flat-square.png)
Expand Down Expand Up @@ -42,28 +45,32 @@ copying outpus.
This will render code chunks and save the outputs! Check out
https://quarto.org/ for more examples on how to use the format.

This .
This ....

```` markdown

```{python}
print(1+1)
print(1+2)
```
````

Will become this
Will become this ...

``` python
print(1+1)
:::: {.cell execution_count="1"}
``` {.python .cell-code}
print(1+2)
```

2
::: {.cell-output .cell-output-stdout}
3
:::
::::

## Installation

1. Make sure you have quarto installed in your computer.

- https://quarto.org/docs/get-started/
- https://quarto.org/docs/get-started/

2. Install `mkquartodocs`

Expand All @@ -85,11 +92,11 @@ plugins:

Available configuration options:

- **quarto_path**: Specifies where to look for the quarto executable.
- **keep_output**: If true it will skip the cleanup step in the
directory.
- **ignore**: a python regular expressions that if matched will mark the
file to not be rendered. Note that they need to be full matches
- **quarto_path**: Specifies where to look for the quarto executable.
- **keep_output**: If true it will skip the cleanup step in the
directory.
- **ignore**: a python regular expressions that if matched will mark
the file to not be rendered. Note that they need to be full matches

``` yaml
# Whatever is in your mkdocs.yml configuration file....
Expand All @@ -113,7 +120,10 @@ files, render them, generate the output and clean after itself.

The things that need to/could be added to the project:

- [ ] quarto project support
- [ ] render in temporary directory, posibly with a ‘safe’ argument
- [ ] addition of files not in the docs directory, ‘include’ argument
- [ ] add readme to testing data
- [ ] quarto project support
- [ ] render in temporary directory, posibly with a 'safe' argument
- [ ] addition of files not in the docs directory, 'include' argument
- [ ] add readme to testing data
- [ ] move
`INFO - mkquartodocs: Running RemoveCellDataPreprocessor` to
debug log
4 changes: 2 additions & 2 deletions docs/README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ This ....
````

```{{python}}
print(1+1)
print(1+2)
```

````

Will become this ...

```{python}
print(1+1)
print(1+2)
```

## Installation
Expand Down
18 changes: 11 additions & 7 deletions mkquartodocs/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

class AdmotionCellDataPreprocessor(Preprocessor):
CELL_REGEX: Final = re.compile(r"^::: \{\.cell .*}\s*$")
CELL_END: Final = re.compile(r"^:::$")
CELL_END: Final = re.compile(r"^:{3,4}?$")
CELL_ELEM_REGEX: Final = re.compile(
r"^::: \{(.cell-\w+) (\.cell-[\w-]+)( execution_count=\"\d+\")?\}$"
r"^:{3,4} \{(\.cell(-\w+)?)\s?(\.cell-[\w-]+)?( execution_count=\"\d+\")?\}"
)
CODEBLOCK_REGEX: Final = re.compile(r"^```{\.(\w+) .*}")

Expand All @@ -34,7 +34,6 @@ def run(self, lines):
outs = [self._process_line(x) for x in lines]
log.debug(f"Removing {sum(1 for x in outs if x is None)} lines")
out = [x for x in outs if x is not None]

return out

def _process_line(self, line):
Expand All @@ -47,12 +46,17 @@ def _process_line(self, line):
out = "\n\n"

elif sr := self.CELL_ELEM_REGEX.search(line):
log.debug(f"Matched Cell element: {line}")
output_type = sr.groups()[1]
out = self.TYPE_MAPPING[output_type]
groups = {i: x for i, x in enumerate(sr.groups())}
log.debug(f"Matched Cell element: {line}, groups: {groups}")
if groups[3]:
out = "\n\n"
else:
output_type = groups[2]
out = self.TYPE_MAPPING[output_type]

elif sr := self.CODEBLOCK_REGEX.search(line):
log.debug(f"Matched codeblock: {line}")
groups = {i: x for i, x in enumerate(sr.groups())}
log.debug(f"Matched codeblock: {line} -> {groups}")
lang = sr.groups(1)
out = f"```{lang}"
else:
Expand Down
4 changes: 3 additions & 1 deletion mkquartodocs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ def on_pre_build(self, config):
[quarto, "render", str(x), "--to=markdown"], check=True
)
break
except subprocess.CalledProcessError:
except subprocess.CalledProcessError as e:
# ERROR: Couldn't find open server
# it ocasionally fails with that error ...
if i == 4:
log.error(f"Quarto failed to render {x} after 5 tries")
log.error(f"Quarto failed with error: {e}")
raise
warnings.warn(f"Quarto failed to render {x}, retrying")
else:
Expand Down
Loading
Loading