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

Major refactor #7

Merged
merged 24 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a5fd62c
fix: avoid exception if no title is specified
sanzoghenzo Jan 25, 2023
ff83b03
fix: pass caption_class test
sanzoghenzo Jan 25, 2023
e8be923
fix: pass caption_prefix test
sanzoghenzo Jan 25, 2023
0aa59d5
chore: add pycharm project folder to gitignore
sanzoghenzo Jan 25, 2023
103ec73
fix: pass caption prefix class test
sanzoghenzo Jan 25, 2023
99c09fe
fix: pass content class test
sanzoghenzo Jan 25, 2023
1402818
fix: pass numbering test
sanzoghenzo Jan 25, 2023
349ae66
fix: pass no strip title test
sanzoghenzo Jan 25, 2023
1a7d194
refactor: use PEP8 style
sanzoghenzo Jan 25, 2023
ef55415
refactor: move to pytest
sanzoghenzo Jan 25, 2023
098390b
refactor: use static methods where applicable
sanzoghenzo Jan 25, 2023
19eeaa0
refactor: split long method
sanzoghenzo Jan 25, 2023
36079c3
refactor: use subclasses
sanzoghenzo Jan 26, 2023
2bcd275
refactor: move content_tag as class attribute
sanzoghenzo Jan 26, 2023
fbaf772
refactor: move defaults where they should be
sanzoghenzo Jan 26, 2023
165ec2c
refactor: remove unused parameter
sanzoghenzo Jan 26, 2023
2eab4cf
refactor: move caption_tag as class attribute
sanzoghenzo Jan 26, 2023
c6b885f
refactor: DRY code
sanzoghenzo Jan 26, 2023
690f9ce
refactor: remove unused parameters
sanzoghenzo Jan 26, 2023
b41825b
docs: update readme
sanzoghenzo Jan 26, 2023
fd90eea
build: setup github actions
sanzoghenzo Jan 26, 2023
7e15b54
build: rename build github action to test
sanzoghenzo Jan 26, 2023
7248133
fix: wrong entrypoint name
sanzoghenzo Jan 26, 2023
b99384c
refactor: avoid nested ifs
sanzoghenzo Jan 26, 2023
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
50 changes: 0 additions & 50 deletions .build.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package
run: |
python setup.py sdist bdist_wheel --universal
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python package

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["2.7", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 setuptools wheel twine pytest pytest-cov
pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=89 --statistics
- name: Test with pytest
run: |
pytest --cov
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/build/
/dist/
/venv/
/.idea/
/.coverage
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Python markdown extensions are incorporated into other applications.
MkDocs users can add *caption* to their generator process by adding it to the
`mkdocs.yml` `markdown_extensions` section:

```python
```yaml
site_name: captionTest
# theme:
# name: material
Expand All @@ -63,23 +63,34 @@ nav:
Python will parse input to Markdown with *caption* as follows:

```python
import caption
import markdown
from caption import CaptionExtension

# ...

outputString = markdown.markdown(inputString, extensions = [caption.captionExtension(numbering=false)])
outputString = markdown.markdown(
input_string, extensions=[CaptionExtension(numbering=False)]
)
```

### Options

Currently supported options are listed below:

* `captionPrefix` (default: `"Figure"`):
* `figure_caption_prefix` (default: `"Figure"`):

The text to show at the front of the caption. A final non-breaking space
is inserted between the content of `captionPrefix` and the actual figure
is inserted between the content of `table_caption_prefix` and the actual figure
number.

* `table_caption_prefix` (default: `"Table"`):

Same as `figure_caption_prefix`, but for tables.

* `listing_caption_prefix` (default: `"Listing"`):

Same as `figure_caption_prefix`, but for listings.

* `numbering` (default: `True`):

Adds a caption number like "Figure 1:" in front of the caption. It's
Expand Down
5 changes: 4 additions & 1 deletion caption/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
# Copyright (c) 2020 flywire
#
# SPDX-License-Identifier: GPL-3.0-or-later
from .caption import makeExtension, captionExtension

from .caption import makeExtension, CaptionExtension

__all__ = ['makeExtension', 'CaptionExtension']
Loading