Skip to content

Commit

Permalink
Removes table of contents from readme
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Mar 21, 2017
1 parent fc125e0 commit e922152
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ target/
# Coconut
tests/dest/
docs/
index.rst
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ test:
.PHONY: docs
docs: clean
sphinx-build -b html . ./docs
cp ./docs/README.html ./docs/index.html
pushd ./docs; zip -r ./docs.zip ./*; popd
rm -rf index.rst

.PHONY: clean
clean:
rm -rf ./docs ./dist ./build ./tests/dest
rm -rf ./docs ./dist ./build ./tests/dest index.rst
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete

Expand Down
20 changes: 20 additions & 0 deletions coconut/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,23 @@ def fixpath(path):
mimetype = "text/x-python3"

all_keywords = keywords + const_vars + reserved_vars

#-----------------------------------------------------------------------------------------------------------------------
# DOCUMENTATION CONSTANTS:
#-----------------------------------------------------------------------------------------------------------------------

without_toc = """
=======
"""

with_toc = """
=======
.. toctree::
:maxdepth: 3
FAQ
HELP
DOCS
CONTRIBUTING
"""
15 changes: 14 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@

from coconut.root import * # NOQA

from coconut.constants import without_toc, with_toc

from recommonmark.parser import CommonMarkParser
from sphinx_bootstrap_theme import get_html_theme_path

#-----------------------------------------------------------------------------------------------------------------------
# README:
#-----------------------------------------------------------------------------------------------------------------------

with open("README.rst", "r") as readme_file:
readme = readme_file.read()

with open("index.rst", "w") as index_file:
index_file.write(readme.replace(without_toc, with_toc))

#-----------------------------------------------------------------------------------------------------------------------
# DEFINITIONS:
#-----------------------------------------------------------------------------------------------------------------------
Expand All @@ -41,8 +53,9 @@
version = VERSION
release = VERSION_STR_TAG

master_doc = "README"
master_doc = "index"
source_suffix = [".rst", ".md"]
source_parsers = {
".md": CommonMarkParser
}
exclude_patterns = ["README.*"]
15 changes: 1 addition & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,7 @@
#-----------------------------------------------------------------------------------------------------------------------

with open("README.rst", "r") as readme_file:
readme_lines = []
in_toc = False
for line in readme_file.readlines():
if line.startswith(".. toctree::"):
in_toc = True
elif in_toc and 0 < len(line.lstrip()) == len(line):
in_toc = False
if not in_toc:
readme_lines.append(line)
readme = "".join(readme_lines)

#-----------------------------------------------------------------------------------------------------------------------
# MAIN:
#-----------------------------------------------------------------------------------------------------------------------
readme = readme_file.read()

setuptools.setup(
name="coconut" + ("-develop" if DEVELOP else ""),
Expand Down

0 comments on commit e922152

Please sign in to comment.