-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from pganssle/update_docs
Redo the README.rst
- Loading branch information
Showing
8 changed files
with
112 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import itertools | ||
import pathlib | ||
import re | ||
import typing | ||
|
||
from setuptools import setup | ||
|
||
ROOT: typing.Final[pathlib.Path] = pathlib.Path(__file__).parent | ||
|
||
|
||
def strip_images(rst_file: pathlib.Path) -> str: | ||
pattern = re.compile(r"(?P<whitespace>\s*).. image:: (?P<path>.*)$") | ||
text = rst_file.read_text() | ||
lines = text.split("\n") | ||
lines_out = [] | ||
in_block = False | ||
indent = None | ||
for line in lines: | ||
if pattern.match(line): | ||
in_block = True | ||
continue | ||
else: | ||
if in_block: | ||
prefix_m = re.match("\s+", line) | ||
if not prefix_m or ( | ||
(indent is not None) and indent != line[slice(*prefix_m.span())] | ||
): | ||
in_block = False | ||
indent = None | ||
else: | ||
if indent is None: | ||
indent = line[slice(*prefix_m.span())] | ||
continue | ||
|
||
lines_out.append(line) | ||
|
||
lines_with_newlines = itertools.groupby(lines_out, key=bool) | ||
lines_with_collapsed_newlines = ( | ||
grp if has_contents else ("",) for has_contents, grp in lines_with_newlines | ||
) | ||
return "\n".join(itertools.chain.from_iterable(lines_with_collapsed_newlines)) | ||
|
||
|
||
setup( | ||
long_description=strip_images(ROOT / "README.rst"), | ||
long_description_content_type="text/x-rst", | ||
) |