Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- internal: Switch from setup.py to a PEP-621 pyproject.toml, from
[Tony Narlock](https://www.git-pull.com).

- Support for markdown `.md` files and `{eval-rst}` myst-parser directives, from
[Tony Narlock](https://www.git-pull.com) (re: #30, via #31).

## [0.4.0] - 2022-03-30
###
- Drop python2.7 (Fixes #14)
Expand Down
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
PY_FILES= find . -type f -not -path '*/\.*' | grep -i '.*[.]py$$' 2> /dev/null
TEST_FILES= find . -type f -not -path '*/\.*' | grep -i '.*[.]\(yaml\|py\)$$' 2> /dev/null
DOC_FILES= find . -type f -not -path '*/\.*' | grep -i '.*[.]rst\$\|.*[.]md\$\|.*[.]css\$\|.*[.]py\$\|mkdocs\.yml\|CHANGES\|TODO\|.*conf\.py' 2> /dev/null
SHELL := /bin/bash

entr_warn:
@echo "----------------------------------------------------------"
@echo " ! File watching functionality non-operational ! "
@echo " "
@echo "Install entr(1) to automatically run tasks on file change."
@echo "See http://entrproject.org/ "
@echo "----------------------------------------------------------"

isort:
isort `${PY_FILES}`

black:
black `${PY_FILES}`

test:
py.test $(test)

start:
$(MAKE) test; ptw .

watch_test:
if command -v entr > /dev/null; then ${TEST_FILES} | entr -c $(MAKE) test; else $(MAKE) test entr_warn; fi

build_docs:
$(MAKE) -C docs html

watch_docs:
if command -v entr > /dev/null; then ${DOC_FILES} | entr -c $(MAKE) build_docs; else $(MAKE) build_docs entr_warn; fi

serve_docs:
$(MAKE) -C docs serve

dev_docs:
$(MAKE) -j watch_docs serve_docs

start_docs:
$(MAKE) -C docs start

design_docs:
$(MAKE) -C docs design

flake8:
flake8

watch_flake8:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) flake8; else $(MAKE) flake8 entr_warn; fi

mypy:
mypy `${PY_FILES}`

watch_mypy:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) mypy; else $(MAKE) mypy entr_warn; fi

format_markdown:
npx prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES
29 changes: 29 additions & 0 deletions examples/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# doctest w/ myst-parser examples

## Barebones `doctest_block`

Welcome, here's my first thing:

```
>>> 2 + 2
4
>>> continents = 7
>>> print(f'hello world, there are {continents} continents')
hello world, there are 7 continents
```

## sphinx.ext.doctest-like directives (basic)

Another:

```{doctest} My example
>>> 2 + 3
5
```

```{doctest} A second
>>> 1 + 8
9
>>> 2 - 8
-6
```
6 changes: 6 additions & 0 deletions examples/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def add(x: int, y: int) -> int:
"""
>>> add(2, 2)
4
"""
return x + y
33 changes: 33 additions & 0 deletions examples/test.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
doctest examples
================

Plain-old `doctest_block`
-------------------------

>>> print(f'this is a doctest block: 2 + 2 = {2 + 2}')
this is a doctest block: 2 + 2 = 4

They end with a blank line

sphinx.ext.doctest-like directives (basic)
------------------------------------------

.. doctest::

>>> 2 + 2
4

.. doctest:: Our example

>>> round(
... 3.9
... )
4

.. doctest:: Here's a function

>>> def shout(message: str) -> str:
... print(f'{message.upper()}')

>>> shout('hello')
HELLO
2 changes: 2 additions & 0 deletions examples/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>>> 2 + 2
4
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ classifiers = [
# Requirements
dependencies = [
"pytest >=7.0.0",
"docutils"
]

[project.optional-dependencies]
Expand All @@ -41,6 +42,9 @@ lint = [
"black",
"mypy"
]
myst-parser = [
"myst-parser"
]

[project.urls]
homepage = "https://github.com/thisch/pytest-sphinx"
Expand Down
Loading