Skip to content

Commit

Permalink
feat(m2r): use m2r to convert automatic .md files to .rst
Browse files Browse the repository at this point in the history
* https://github.com/miyakogi/m2r
  - Markdown to reStructuredText converter
  • Loading branch information
myii committed Mar 3, 2019
1 parent 1a26fdd commit b86ddf4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ ENV/

# mypy
.mypy_cache/

# copied `.md` files used for conversion to `.rst` using `m2r`
docs/*.md
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Welcome to template-formula's documentation!
============================================

.. toctree::
:maxdepth: 3
:maxdepth: 2
:caption: Contents
:numbered:
:glob:

README <README>
CONTRIBUTING
TOFS_pattern
AUTHORS
CHANGELOG
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
prepareCmd: 'sh ./update_FORMULA.sh ${nextRelease.version}',
}],
['@semantic-release/git', {
assets: ['*.md', 'FORMULA'],
assets: ['*.md', 'docs/*.rst', 'FORMULA'],
}],
'@semantic-release/github',
],
Expand Down
28 changes: 28 additions & 0 deletions update_FORMULA.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
#!/bin/sh

###############################################################################
# (A) Update `FORMULA` with `${nextRelease.version}`
###############################################################################
sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA


###############################################################################
# (B) Use `m2r` to convert automatically produced `.md` docs to `.rst`
###############################################################################

# Install `m2r`
sudo -H pip install m2r

# Copy and then convert the `.md` docs
cp *.md docs/
cd docs/
m2r --overwrite *.md

# Change excess `H1` headings to `H2` in converted `CHANGELOG.rst`
sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst
sed -i -e '1,4s/-/=/g' CHANGELOG.rst

# Use for debugging output, when required
# cat AUTHORS.rst
# cat CHANGELOG.rst

# Return back to the main directory
cd ..

0 comments on commit b86ddf4

Please sign in to comment.