tools: Add color to pydoc.
This commit is contained in:
parent
1925f53bf8
commit
a1199a1767
4 changed files with 36 additions and 12 deletions
25
eris/pydoc_color.py
Executable file
25
eris/pydoc_color.py
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3.7
|
||||
|
||||
# Copyright (C) 2019 Andrew Hamilton. All rights reserved.
|
||||
# Licensed under the Artistic License 2.0.
|
||||
|
||||
|
||||
import pydoc
|
||||
import sys
|
||||
|
||||
import eris.termstr
|
||||
|
||||
|
||||
class TermDoc(pydoc.TextDoc):
|
||||
|
||||
def bold(self, text):
|
||||
return str(eris.termstr.TermStr(text).bold())
|
||||
|
||||
|
||||
def main():
|
||||
path = sys.argv[1]
|
||||
print(pydoc.render_doc(pydoc.importfile(path), renderer=TermDoc()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -296,17 +296,6 @@ def pytest(path):
|
|||
return status, (stdout + stderr)
|
||||
|
||||
|
||||
@deps(url="https://docs.python.org/3/library/pydoc.html")
|
||||
def pydoc(path):
|
||||
stdout, stderr, returncode = _do_command(
|
||||
[PYTHON_EXECUTABLE, "-m", "pydoc", path], timeout=TIMEOUT)
|
||||
status = Status.normal if returncode == 0 else Status.not_applicable
|
||||
if not stdout.startswith("Help on module"):
|
||||
status = Status.not_applicable
|
||||
stdout = stdout.replace(os.getcwd() + "/", "")
|
||||
return status, _fix_input(stdout)
|
||||
|
||||
|
||||
@deps(deps={"pip/mypy"}, url="http://mypy-lang.org/", executables={"mypy"})
|
||||
def mypy(path):
|
||||
stdout, stderr, returncode = _do_command(
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@ tools_for_extensions = [
|
|||
url = "https://en.wikipedia.org/wiki/Python_syntax_and_semantics"
|
||||
command = "python3.7 -m py_compile"
|
||||
|
||||
[pydoc]
|
||||
dependencies = []
|
||||
url = "https://docs.python.org/3/library/pydoc.html"
|
||||
command = "pydoc_color"
|
||||
success_status = "normal"
|
||||
error_status = "not_applicable"
|
||||
has_color = true
|
||||
timeout = 60
|
||||
|
||||
[pycodestyle]
|
||||
dependencies = ["pip/pycodestyle"]
|
||||
url = "http://pycodestyle.pycqa.org/en/latest/"
|
||||
|
|
|
|||
3
setup.py
3
setup.py
|
|
@ -22,4 +22,5 @@ setup(name="eris",
|
|||
entry_points={"console_scripts":
|
||||
["eris=eris.__main__:entry_point",
|
||||
"eris-worker=eris.worker:main",
|
||||
"eris-webserver=eris.webserver:main"]})
|
||||
"eris-webserver=eris.webserver:main",
|
||||
"pydoc_color=eris.pydoc_color:main"]})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue