Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
860f23b
Reorganized resources page
jrg94 Apr 10, 2023
1e4f7f2
Expanded MDList docs
jrg94 Apr 10, 2023
40f8d19
Cleaned up MDList docs
jrg94 Apr 10, 2023
aec2ccb
Added a value error for checklist mismatches
jrg94 Apr 10, 2023
c36d473
Added raises exception to docs
jrg94 Apr 10, 2023
dd8f69b
Added value error for checklist issues
jrg94 Apr 10, 2023
06700be
Added a nested test
jrg94 Apr 10, 2023
2150a07
Incremented beta to b2
jrg94 Apr 10, 2023
d7b1adf
Working through better documenting params
jrg94 Apr 10, 2023
1da680c
Cleaned up inline text docs
jrg94 Apr 10, 2023
6fbfcc7
Added my first doctest
jrg94 Apr 10, 2023
0037d37
Toying with doctest
jrg94 Apr 10, 2023
78d2b1e
Added str definition to docs
jrg94 Apr 10, 2023
0b96ce4
Working through code samples
jrg94 Apr 10, 2023
8161668
Working through doctests
jrg94 Apr 10, 2023
8dcfd55
Slowly working through tests
jrg94 Apr 10, 2023
92d1724
Updated action
jrg94 Apr 10, 2023
301d31d
Fully tested inline
jrg94 Apr 10, 2023
2d5d69a
Fixed up element API
jrg94 Apr 10, 2023
bd0b73d
Slightly reworked promote
jrg94 Apr 10, 2023
208044a
Composed 40 doctests
jrg94 Apr 10, 2023
e3fc903
Working through code examples
jrg94 Apr 10, 2023
a717068
Caught a nasty bug in table
jrg94 Apr 10, 2023
84d2e60
Working through doctests
jrg94 Apr 10, 2023
46faf48
Added ordered list test
jrg94 Apr 10, 2023
495cade
Added table doctests
jrg94 Apr 10, 2023
0afda71
Added code code block
jrg94 Apr 10, 2023
6e3d16f
Added doctests for entire repo
jrg94 Apr 10, 2023
e890c4e
Added fluent interface pattern to docs
jrg94 Apr 10, 2023
98790fa
Working through docs
jrg94 Apr 10, 2023
e2e1591
Added missing docs to Code
jrg94 Apr 10, 2023
5704cef
Cleaned up docs
jrg94 Apr 10, 2023
efa1bfe
Fixed escape sequence
jrg94 Apr 10, 2023
2c25e2e
Added sphinx reqs to build as well
jrg94 Apr 10, 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
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PyTest
name: PyTest & Doctest

on:
pull_request:
Expand All @@ -24,9 +24,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r docs/requirements.txt

- name: PyTest
run: coverage run --source=snakemd -m pytest

- name: Coverage
run: coverage report

- name: Doctest
run: |
cd docs
make doctest
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', "sphinx_issues", 'sphinx.ext.intersphinx']
extensions = [
'sphinx.ext.autodoc',
'sphinx_issues',
'sphinx.ext.intersphinx',
'sphinx.ext.doctest'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
27 changes: 19 additions & 8 deletions docs/docs/element-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ is known as an element. Below is the element interface.
:show-inheritance:
:special-members: __str__

For consistency, element mutators all return self to allow
for method chaining. This is sometimes referred to as the
fluent interface pattern, and it's particularly useful
for applying a series of changes to a single element. This
design choice most obviously shines in both :class:`snakemd.Paragraph`,
which allows different aspects of the text to be replaced
over a series of chained methods, and :class:`snakemd.Inline`,
which allows inline elements to be styled over a series of
chained methods.

For practical purposes, elements cannot be constructed directly.
Instead, they are broken down into two main categories:
block and inline.
Expand All @@ -31,11 +41,11 @@ custom blocks using the :func:`snakemd.Document.add_block` method. To make use
of this method, blocks must be imported and constructed manually,
like the following :class:`snakemd.Heading` example:

.. code-block:: python
.. doctest:: block

from snakemd import Heading, new_doc
doc = new_doc()
doc.add_block(Heading("Hello, World!", 2))
>>> from snakemd import Heading, new_doc
>>> doc = new_doc()
>>> heading = doc.add_block(Heading("Hello, World!", 2))

The remainder of this section introduces the Block interface
as well as all of the Blocks currently available for use.
Expand Down Expand Up @@ -135,11 +145,11 @@ the returned Heading object has no support for linking. However,
with Inline elements, we can create a custom Heading to our
standards:

.. code-block:: python
.. doctest:: inline

from snakemd import Heading, Inline, new_doc
doc = new_doc()
doc.add_block(Heading(Inline("Hello, World!", "https://snakemd.io"), 2))
>>> from snakemd import Heading, Inline, new_doc
>>> doc = new_doc()
>>> heading = doc.add_block(Heading(Inline("Hello, World!", "https://snakemd.io"), 2))

The remainder of this section introduces the Inline class.

Expand All @@ -150,3 +160,4 @@ Inline
:members:
:undoc-members:
:show-inheritance:
:special-members: __str__
6 changes: 3 additions & 3 deletions docs/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ date, with the most recently published resources first.
v2.x
----

- TBD
* **2023-04-14**: `How to Migrate to SnakeMD 2.0.0 <https://therenegadecoder.com/code/how-to-migrate-to-snakemd-2-0-0/>`_
* **2022-05-13**: `The Complete Guide to SnakeMD: A Python Library for Generating Markdown <https://therenegadecoder.com/code/the-complete-guide-to-snakemd-a-python-library-for-generating-markdown/>`_

v0.x
----

* **2022-05-13**: `The Complete Guide to SnakeMD: A Python Library for Generating Markdown <https://therenegadecoder.com/code/the-complete-guide-to-snakemd-a-python-library-for-generating-markdown/>`_
* **2022-01-22**: `SnakeMD 0.10.x Features Checklists <https://therenegadecoder.com/meta/snakemd-0-10-x-features-checklists/>`_
* **2021-09-24**: `How to Generate Markdown in Python Using SnakeMD <https://therenegadecoder.com/code/how-to-generate-markdown-in-python-using-snakemd/>`_
* **2021-09-24**: `How to Generate Markdown in Python Using SnakeMD v0.x <https://therenegadecoder.com/code/how-to-generate-markdown-in-python-using-snakemd/>`_
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
MAJOR = 2
MINOR = 0
PATCH = 0
PRE = "b2"

name = "SnakeMD"
version = f"{MAJOR}.{MINOR}"
release = f"{MAJOR}.{MINOR}.{PATCH}b1"
release = f"{MAJOR}.{MINOR}.{PATCH}{PRE}"
setuptools.setup(
name=name,
version=release,
Expand Down
8 changes: 4 additions & 4 deletions snakemd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def new_doc() -> Document:
wants to take advantage of the procedural interface of SnakeMD.
For those looking for a bit more control, each element class
will need to be imported as needed.

.. code-block:: Python

doc = snakemd.new_doc()
.. doctest:: document
>>> doc = snakemd.new_doc()

:return:
a new Document object
Expand Down
Loading