pycommons.dev package¶
Developer tools. Process a markdown file in order to make it useful for distribution. In order to let sphinx properly load and insert the README.md file into the project’s documentation, we need to process this file from the GitHub style markdown to a variant suitable for the myst parser used in sphinx. While we are at it, we can also turn absolute URLs from the GitHub-README.md file that point to the documentation URL to relative URLs. Create the url replacers that fix absolute to relative URLs. a single callable that can process strings and fix the URLs therein TypeError – if any of the inputs is of the wrong type ValueError – if any of the inputs is incorrectSubpackages¶
Submodules¶
pycommons.dev.url_replacer module¶
>>> f = make_url_replacer(None, None)
>>> f("1")
'1'
>>> f = make_url_replacer({"https://example.com/1": "./a/",
... "https://example.com": "./"},
... {"https://example.com/1/1.txt": "y.txt",
... "https://example.com/x/1.txt": "z.txt"})
>>> f("<a href='http://example.com/1/2.txt' />")
'<a href="./a/2.txt" />'
>>> f("<a href='http://example.com/1' />")
'<a href="./a/" />'
>>> f("<a href='http://example.com' />")
'<a href="./" />'
>>> f("<a href='http://example.com/x.txt' />")
'<a href="./x.txt" />'
>>> f("<a href='http://example.com/1/1.txt' />")
'<a href="y.txt" />'
>>> f("<a href='http://example.com/x/1.txt' />")
'<a href="z.txt" />'
>>> try:
... make_url_replacer(1, None)
... except TypeError as te:
... print(te)
base_urls should be an instance of typing.Mapping but is int, namely 1.
>>> try:
... make_url_replacer(None, 1)
... except TypeError as te:
... print(te)
full_urls should be an instance of typing.Mapping but is int, namely 1.
>>> try:
... make_url_replacer(None, None, None)
... except TypeError as te:
... print(te)
for_markdown should be an instance of bool but is None.
>>> try:
... make_url_replacer(None, None, 1)
... except TypeError as te:
... print(te)
for_markdown should be an instance of bool but is int, namely 1.