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

Move to markdown-it-py parser #123

Merged
merged 33 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1d84c69
Move to markdown-it parser
chrisjsewell Mar 26, 2020
b078d0f
updates
chrisjsewell Mar 27, 2020
bc0f77f
remove archive
chrisjsewell Mar 27, 2020
303c537
Fix tests
chrisjsewell Mar 27, 2020
4a42c10
Update pydata-sphinx-theme requirement
chrisjsewell Mar 27, 2020
12b0bf1
Add nested footnote test
chrisjsewell Mar 27, 2020
5306dc1
Move testing to GitHub
chrisjsewell Mar 27, 2020
6be709d
Add github CI badges
chrisjsewell Mar 27, 2020
22eb218
Update conf.py
chrisjsewell Mar 27, 2020
b8fb808
Partial update of documentation
chrisjsewell Mar 27, 2020
615d052
test fix
chrisjsewell Mar 27, 2020
7d98dbf
fix docs
chrisjsewell Mar 27, 2020
0a1d53e
Update documentation
chrisjsewell Mar 27, 2020
f20333d
Improve coverage
chrisjsewell Mar 27, 2020
e65142b
improve test coverage
chrisjsewell Mar 27, 2020
89a1779
Add test
chrisjsewell Mar 27, 2020
6214cd9
Update use_api.md
chrisjsewell Mar 27, 2020
626e5c5
Bump markdown-it-py version
chrisjsewell Mar 28, 2020
d132cd2
Test reporter warnings
chrisjsewell Mar 28, 2020
4fcf732
Add tests and fixes for reporter warnings and include directive
chrisjsewell Mar 28, 2020
cd83c70
Add documentation of sphinx parser options
chrisjsewell Mar 28, 2020
77af8e1
bump version for alpha release
chrisjsewell Mar 28, 2020
95a0404
Apply doc fixes suggested by @rossbar in #121
chrisjsewell Mar 28, 2020
034be2a
Update __init__.py
chrisjsewell Mar 28, 2020
c97d2d7
bump markdown-it-py version
chrisjsewell Mar 29, 2020
81d0bfb
Bump markdown-it-py version
chrisjsewell Mar 29, 2020
e64898a
Update conf.py
chrisjsewell Mar 29, 2020
d53a9b5
Add title to image node
chrisjsewell Mar 30, 2020
826015f
Add warning for non-consecutive headings
chrisjsewell Mar 30, 2020
63f0e3e
test fix
chrisjsewell Mar 30, 2020
73db682
Update bug_report.md
chrisjsewell Mar 30, 2020
60ea3a2
Bump markdown-it version (allow multi-line inline math)
chrisjsewell Apr 1, 2020
e2c8252
Update __init__.py
chrisjsewell Apr 1, 2020
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
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- cache-pip
- run: |
pip install --user -e .[sphinx,rtd]
pip install -r docs/requirements.txt
- save_cache:
key: cache-pip
paths:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on: [push, pull_request]
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[sphinx,code_style,testing]
- name: Pre-commit checks
run: |
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
# cd tests/test_commonmark && ./spec.sh
- name: Test with pytest
run: |
pip install pytest
pytest --cov=myst_parser --cov-report=
- name: Upload to coveralls
run: |
pip install coveralls
coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_KEY }}

publish:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is a publish vs. a build triggered? this seems like a useful way to automate releases, just not sure how it works :-)


name: Publish to PyPi
needs: build
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
Comment on lines +48 to +49
Copy link
Member Author

@chrisjsewell chrisjsewell Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@choldgraf, you can give conditionals to each job. In this case the 'publish' job is triggered conditional on the 'build' job passing, and if the full process was triggered by creating a release tag on the repo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shit that's cool! I'm really liking github-actions (I know I know, you're not allowed to make fun of me every time I praise a microsoft product)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆
yeh well in terms of document building, its certainly something we could consider providing our own workflow/action for; something like https://github.com/ammaraskar/sphinx-action (using a Docker environment), but also making use of caching and artefacts: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-and-storing-workflow-data

Copy link
Member

@choldgraf choldgraf Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I am one step ahead of you on that one ;-) even have a friend that works on Microsoft Azure helping out!

https://github.com/ExecutableBookProject/cli/issues/44

runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Build package
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json

# Pyre type checker
.pyre/

_archive/
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ exclude: >
(?x)^(
\.vscode/settings\.json|
tests/test_commonmark/commonmark\.json|
.*\.xml
.*\.xml|
tests/.*/fixtures/.*\.md
)$

repos:
Expand Down
1 change: 0 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ python:
extra_requirements:
- sphinx
- rtd
- requirements: docs/requirements.txt
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"autoDocstring.customTemplatePath": "docstring.fmt.mustache",
"python.pythonPath": "/anaconda/envs/ebp/bin/python"
"python.pythonPath": "/anaconda/envs/ebp/bin/python",
"restructuredtext.confPath": "${workspaceFolder}/docs"
}
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include LICENSE
include myst_parser/cli/spec.md
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MyST-Parser

[![CI Status][travis-badge]][travis-link]
[![Github-CI][github-ci]][github-link]
[![Coverage][coveralls-badge]][coveralls-link]
[![Documentation Status][rtd-badge]][rtd-link]
[![Code style: black][black-badge]][black-link]
Expand Down Expand Up @@ -35,8 +35,8 @@ pip install -e .[sphinx,code_style,testing,rtd]

To use the MyST parser in Sphinx, simply add: `extensions = ["myst_parser"]` to your `conf.py`.

[travis-badge]: https://travis-ci.org/ExecutableBookProject/MyST-Parser.svg?branch=master
[travis-link]: https://travis-ci.org/ExecutableBookProject/MyST-Parser
[github-ci]: https://github.com/ExecutableBookProject/MyST-Parser/workflows/Python%20package/badge.svg?branch=master
[github-link]: https://github.com/ExecutableBookProject/MyST-Parser
[coveralls-badge]: https://coveralls.io/repos/github/ExecutableBookProject/MyST-Parser/badge.svg?branch=master
[coveralls-link]: https://coveralls.io/github/ExecutableBookProject/MyST-Parser?branch=master
[rtd-badge]: https://readthedocs.org/projects/myst-parser/badge/?version=latest
Expand Down
1 change: 0 additions & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
```{toctree}
:maxdepth: 2

tokens.rst
directive.rst
renderers.rst
sphinx_parser.rst
Expand Down
70 changes: 34 additions & 36 deletions docs/api/renderers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,69 @@
MyST Renderers
--------------

MyST-Parser builds on the mistletoe
:ref:`core renderers <mistletoe:renderers/core>`
by including the extended tokens, listed in :ref:`api/tokens`,
and adding bridges to docutils/sphinx:

HTML
....
These renderers take the markdown-it parsed token stream and convert it to
the docutils AST. The sphinx renderer is a subclass of the docutils one,
with some additional methods only available *via* sphinx
.e.g. multi-document cross-referencing.

.. autoclass:: myst_parser.html_renderer.HTMLRenderer
:special-members: __init__, __enter__, __exit__
:members: default_block_tokens, default_span_tokens
:undoc-members:
:member-order: alphabetical
:show-inheritance:

Docutils
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a dogfooding perspective I feel like these should be written in markdown :-) (not blocking this PR though)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why its not is because, autodoc has to read the python docstrings as rST. I'm sure you could get it to read them as markdown (and rewrite all you doctrings as such), but I doubt its worth the hassle!

........

JSON
....

.. autoclass:: myst_parser.json_renderer.JsonRenderer
:special-members: __init__, __enter__, __exit__
:members: default_block_tokens, default_span_tokens
.. autoclass:: myst_parser.docutils_renderer.DocutilsRenderer
:special-members: __output__, __init__
:members: render, nested_render_text, add_line_and_source_path, current_node_context
:undoc-members:
:member-order: alphabetical
:member-order: bysource
:show-inheritance:

Docutils
........

.. autoclass:: myst_parser.docutils_renderer.DocutilsRenderer
:special-members: __init__, __enter__, __exit__
:members: default_block_tokens, default_span_tokens, new_document
Sphinx
......

.. autoclass:: myst_parser.sphinx_renderer.SphinxRenderer
:special-members: __output__
:members: handle_cross_reference, render_math_block_eqno
:undoc-members:
:member-order: alphabetical
:show-inheritance:

Mocking
.......

These classes are parsed to sphinx roles and directives,
to mimic the original docutls rST specific parser elements,
but instead run nested parsing with the markdown parser.

.. autoclass:: myst_parser.docutils_renderer.MockInliner
. autoclass:: myst_parser.mocking.MockInliner
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: myst_parser.docutils_renderer.MockState
.. autoclass:: myst_parser.mocking.MockState
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: myst_parser.docutils_renderer.MockStateMachine
.. autoclass:: myst_parser.mocking.MockStateMachine
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: myst_parser.docutils_renderer.MockIncludeDirective
.. autoclass:: myst_parser.mocking.MockIncludeDirective
:members:
:undoc-members:
:show-inheritance:

Sphinx
......

.. autoclass:: myst_parser.docutils_renderer.SphinxRenderer
:special-members: __init__, __enter__, __exit__
:members: default_block_tokens, default_span_tokens, mock_sphinx_env
:undoc-members:
:member-order: alphabetical
:show-inheritance:
Additional Methods
..................

.. autofunction:: myst_parser.docutils_renderer.make_document

.. autofunction:: myst_parser.docutils_renderer.dict_to_docinfo

.. autofunction:: myst_parser.sphinx_renderer.minimal_sphinx_app

.. autofunction:: myst_parser.sphinx_renderer.mock_sphinx_env
2 changes: 1 addition & 1 deletion docs/api/sphinx_parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Sphinx Parser
-------------

This class builds on the :py:class:`~myst_parser.docutils_renderer.SphinxRenderer`
This class builds on the :py:class:`~myst_parser.sphinx_renderer.SphinxRenderer`
to generate a parser for Sphinx, using the :ref:`Sphinx parser API <sphinx:parser-api>`:

.. autoclass:: myst_parser.sphinx_parser.MystParser
Expand Down
55 changes: 0 additions & 55 deletions docs/api/tokens.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "pandas_sphinx_theme"
html_theme = "pydata_sphinx_theme"
html_logo = "_static/logo.png"

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down
11 changes: 2 additions & 9 deletions docs/develop/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
This page describes implementation details to help you understand the structure
of the project.

```{note}
MyST currently relies on
[a fork of the Mistletoe project](https://github.com/ExecutableBookProject/mistletoe).
We hope to upstream these changes, but in the meantime make sure that you are using
this fork.
```
## A Renderer for markdown-it tokens

## An extension to Mistletoe syntax

At a high level, the MyST parser is an extension of the Mistletoe project. Mistletoe
At a high level, the MyST parser is an extension of th project. Markdown-It-Py
is a well-structured Python parser for CommonMark text. It also defines an extension
point to include more syntax in parsed files. The MyST parser uses this extension
point to define its own syntax options (e.g., for Sphinx roles and directives).
Expand Down
6 changes: 3 additions & 3 deletions docs/develop/contributing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

[![CI Status][travis-badge]][travis-link]
[![Github-CI][github-ci]][github-link]
[![Coverage][coveralls-badge]][coveralls-link]
[![CircleCI][circleci-badge]][circleci-link]
[![Documentation Status][rtd-badge]][rtd-link]
Expand Down Expand Up @@ -70,8 +70,8 @@ Merging pull requests: There are three ways of 'merging' pull requests on GitHub
- Merge with merge commit: put all commits as they are on the base branch, with a merge commit on top
Choose for collaborative PRs with many commits. Here, the merge commit provides actual benefits.

[travis-badge]: https://travis-ci.org/ExecutableBookProject/MyST-Parser.svg?branch=master
[travis-link]: https://travis-ci.org/ExecutableBookProject/MyST-Parser
[github-ci]: https://github.com/ExecutableBookProject/MyST-Parser/workflows/Python%20package/badge.svg?branch=master
[github-link]: https://github.com/ExecutableBookProject/MyST-Parser
[coveralls-badge]: https://coveralls.io/repos/github/ExecutableBookProject/MyST-Parser/badge.svg?branch=master
[coveralls-link]: https://coveralls.io/github/ExecutableBookProject/MyST-Parser?branch=master
[circleci-badge]: https://circleci.com/gh/ExecutableBookProject/MyST-Parser.svg?style=shield
Expand Down
Loading