Skip to content

Commit 425b218

Browse files
authored
Merge branch 'master' into punk778-patch-1
2 parents eb9967e + 981e58c commit 425b218

32 files changed

+2604
-237
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy Sphinx documentation to Pages
2+
3+
on:
4+
push:
5+
branches: [master] # branch to trigger deployment
6+
7+
jobs:
8+
pages:
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: github-pages
12+
url: ${{ steps.deployment.outputs.page_url }}
13+
permissions:
14+
pages: write
15+
id-token: write
16+
steps:
17+
- id: deployment
18+
uses: sphinx-notes/pages@v3
19+
with:
20+
pyproject_extras: 'test'
21+
sphinx_build_options: '-b dirhtml'

.github/workflows/python-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: [3.7, 3.8, 3.9]
19+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2020

2121
steps:
2222
- uses: actions/checkout@v2
@@ -26,14 +26,14 @@ jobs:
2626
python-version: ${{ matrix.python-version }}
2727
- name: Setup
2828
run: |
29-
python -m pip install -r dev-requirements.txt
29+
python -m pip install .[test]
3030
- name: Lint
3131
run: |
3232
# stop the build if there are Python syntax errors or undefined names
3333
flake8 . --show-source --statistics
3434
- name: Test code
3535
run: |
36-
nosetests --with-coverage --cover-package=mathparse
36+
python -m unittest discover -s tests
3737
- name: Test documentation
3838
run: |
3939
sphinx-build -nW -b html ./docs/ ./build/

.github/workflows/pythonpublish.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __pycache__/
1010
.Python
1111
env/
1212
build/
13+
html/
1314
develop-eggs/
1415
dist/
1516
downloads/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Gunther Cox
3+
Copyright (c) 2025 Gunther Cox
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# mathparse
2+
3+
The `mathparse` library is a Python module designed to evaluate mathematical equations contained in strings.
4+
5+
Here are a few examples:
6+
7+
```python
8+
from mathparse import mathparse
9+
10+
mathparse.parse('50 * (85 / 100)')
11+
>>> 42.5
12+
13+
mathparse.parse('one hundred times fifty four', language='ENG')
14+
>>> 5400
15+
16+
mathparse.parse('(seven * nine) + 8 - (45 plus two)', language='ENG')
17+
>>> 24
18+
```
19+
20+
## Security
21+
22+
Mathparse does not employ the use of Python's [`eval` function](https://docs.python.org/3/library/functions.html#eval) when evaluating provided mathematical expressions. This is a measure to prevent arbitrary code execution vulnerabilities. See https://mathparse.chatterbot.us/postfix/ for additional details.
23+
24+
Mathparse is a standalone Python package and requires zero dependencies to function.
25+
26+
## Language Support
27+
28+
The language parameter must be set in order to evaluate an equation that uses word operators.
29+
The language code should be a valid [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php) language code.
30+
31+
## Installation
32+
33+
```bash
34+
pip install mathparse
35+
```
36+
37+
## Documentation
38+
39+
See the full documentation at https://mathparse.chatterbot.us
40+
41+
## Changelog
42+
43+
See [release notes](https://github.com/gunthercox/mathparse/releases) for changes.

README.rst

Lines changed: 0 additions & 44 deletions
This file was deleted.

dev-requirements.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/_ext/canonical.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Add GitHub repository details to the Sphinx context.
3+
"""
4+
5+
6+
def setup_canonical_func(app, pagename, templatename, context, doctree):
7+
"""
8+
Return the url to the specified page on GitHub.
9+
10+
(Sphinx 7.4 generates a canonical link with a .html extension even
11+
when run in dirhtml mode)
12+
"""
13+
14+
conf = app.config
15+
16+
def canonical_func():
17+
# Special case for the root index page
18+
if pagename == 'index':
19+
return conf.html_baseurl
20+
21+
dir_name = pagename.replace('/index', '/')
22+
return f'{conf.html_baseurl}{dir_name}'
23+
24+
# Add it to the page's context
25+
context['canonical_url'] = canonical_func
26+
27+
28+
# Extension setup function
29+
def setup(app):
30+
app.connect('html-page-context', setup_canonical_func)

docs/_ext/github.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Add GitHub repository details to the Sphinx context.
3+
"""
4+
5+
GITHUB_USER = 'gunthercox'
6+
GITHUB_REPO = 'mathparse'
7+
8+
9+
def setup_github_func(app, pagename, templatename, context, doctree):
10+
"""
11+
Return the url to the specified page on GitHub.
12+
"""
13+
14+
github_version = 'master'
15+
docs_path = 'docs'
16+
17+
def my_func():
18+
return (
19+
f'https://github.com/{GITHUB_USER}/{GITHUB_REPO}/blob/'
20+
f'{github_version}/{docs_path}/{pagename}.rst'
21+
)
22+
23+
# Add it to the page's context
24+
context['github_page_link'] = my_func
25+
26+
27+
# Extension setup function
28+
def setup(app):
29+
app.connect('html-page-context', setup_github_func)

0 commit comments

Comments
 (0)