Skip to content

Commit e9ed87c

Browse files
authored
Merge branch 'main' into update-formatters
2 parents b73aea4 + 8a36bb0 commit e9ed87c

File tree

2 files changed

+51
-34
lines changed

2 files changed

+51
-34
lines changed

hooks/post_gen_project.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/env python3
22
from subprocess import run
3+
{% if not cookiecutter._render_devdocs %}
34
from pathlib import Path
45

56
# Post processing
6-
{% if not cookiecutter._render_devdocs %}
77
Path("docs/template_usage.md").unlink()
88
{% endif %}
99

@@ -14,54 +14,56 @@
1414
# The following output was generated using rich
1515
# The formatted output is included here directly, because I don't want
1616
# rich as another dependency for initalizing the repo.
17-
# See .make_rich_output.py for more details.
17+
# Regenerate using `cd scripts; hatch run python -m scverse_template_scripts.make_rich_output`
1818
print("""
1919
2020
2121
2222
23-
╔══════════════════════════════════════════════════════════════════════╗
24-
[1mSet-up online services[0m
25-
╚══════════════════════════════════════════════════════════════════════╝
23+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
24+
\x1b[1mSet-up online services\x1b[0m
25+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2626
27-
[1mYour repository is now ready. However, to use all features of the [0m
28-
[1mtemplate you will need to set up the following online services.[0m Clicking
27+
\x1b[1mYour repository is now ready.\x1b[0m\x1b[1m \x1b[0m\x1b[1mHowever, to use all features of the \x1b[0m
28+
\x1b[1mtemplate you will need to set up the following online services.\x1b[0m Clicking
2929
on the links will take you to the respective sections of the developer
3030
documentation. The developer documentation is also shipped as part of
3131
the template in docs/developer_docs.md.
3232
33-
[1;33m 1 [0m]8;id=633754;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#pre-commit-checks\[94mpre-commit.ci[0m]8;;\ to check for inconsistencies and to enforce a code
34-
[1;33m [0mstyle
35-
[1;33m 2 [0m]8;id=858259;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#documentation-on-readthedocs\[94mreadthedocs.org[0m]8;;\ to build and host documentation
36-
[1;33m 3 [0m]8;id=497293;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#coverage-tests-with-codecov\[94mcodecov[0m]8;;\ to generate test coverage reports
33+
\x1b[1;33m 1 \x1b[0m\x1b]8;id=994867;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#pre-commit-checks\x1b\\\x1b[4;34mpre-commit.ci\x1b[0m\x1b]8;;\x1b\\ to check for inconsistencies and to enforce a code
34+
\x1b[1;33m \x1b[0mstyle
35+
\x1b[1;33m 2 \x1b[0m\x1b]8;id=697682;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#documentation-on-readthedocs\x1b\\\x1b[4;34mreadthedocs.org\x1b[0m\x1b]8;;\x1b\\ to build and host documentation
36+
\x1b[1;33m 3 \x1b[0m\x1b]8;id=723197;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#coverage-tests-with-codecov\x1b\\\x1b[4;34mcodecov\x1b[0m\x1b]8;;\x1b\\ to generate test coverage reports
3737
3838
All CI checks should pass, you are ready to start developing your new
3939
tool!
4040
41-
╔══════════════════════════════════════════════════════════════════════╗
42-
[1mInstall the package[0m
43-
╚══════════════════════════════════════════════════════════════════════╝
41+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
42+
\x1b[1mInstall the package\x1b[0m
43+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
4444
4545
To run tests or build the documentation locally, you need to install
4646
your package and its dependencies. You can do so with
4747
48-
pip install ".[test,dev,doc]" 
48+
\x1b[40m \x1b[0m
49+
\x1b[40m \x1b[0m\x1b[97;40mpip\x1b[0m\x1b[97;40m \x1b[0m\x1b[97;40minstall\x1b[0m\x1b[97;40m \x1b[0m\x1b[93;40m".[test,dev,doc]"\x1b[0m\x1b[40m \x1b[0m\x1b[40m \x1b[0m
50+
\x1b[40m \x1b[0m
4951
50-
╔══════════════════════════════════════════════════════════════════════╗
51-
[1mCustomizations[0m
52-
╚══════════════════════════════════════════════════════════════════════╝
52+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
53+
\x1b[1mCustomizations\x1b[0m
54+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
5355
54-
Further instructions on using this template can be found in the ]8;id=447180;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html\[94mdev docs[0m]8;;\
55-
]8;id=447180;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html\[94mincluded in the project[0m]8;;\.
56+
Further instructions on using this template can be found in the \x1b]8;id=736137;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html\x1b\\\x1b[4;34mdev docs\x1b[0m\x1b]8;;\x1b\\
57+
\x1b]8;id=736137;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html\x1b\\\x1b[4;34mincluded in the project\x1b[0m\x1b]8;;\x1b\\.
5658
57-
╔══════════════════════════════════════════════════════════════════════╗
58-
[1mCommittment[0m
59-
╚══════════════════════════════════════════════════════════════════════╝
59+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
60+
\x1b[1mCommitment\x1b[0m
61+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
6062
6163
We expect developers of scverse ecosystem packages to
6264
63-
[1;33m • [0m]8;id=169559;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#writing-tests\[94mwrite unit tests[0m]8;;\
64-
[1;33m • [0m]8;id=20647;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#writing-documentation\[94mprovide documentation[0m]8;;\, including tutorials where applicable
65-
[1;33m • [0msupport users through github and the ]8;id=496112;https://discourse.scverse.org/\[94mscverse discourse[0m]8;;\
65+
\x1b[1;33m • \x1b[0m\x1b]8;id=213267;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#writing-tests\x1b\\\x1b[4;34mwrite unit tests\x1b[0m\x1b]8;;\x1b\\
66+
\x1b[1;33m • \x1b[0m\x1b]8;id=972096;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#writing-documentation\x1b\\\x1b[4;34mprovide documentation\x1b[0m\x1b]8;;\x1b\\, including tutorials where applicable
67+
\x1b[1;33m • \x1b[0msupport users through github and the \x1b]8;id=997067;https://discourse.scverse.org/\x1b\\\x1b[4;34mscverse discourse\x1b[0m\x1b]8;;\x1b\\
6668
6769
""")

scripts/src/scverse_template_scripts/make_rich_output.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from __future__ import annotations
22

3+
import io
4+
import re
5+
36
from rich.console import Console
47
from rich.markdown import Markdown
58

@@ -51,14 +54,26 @@
5154

5255

5356
def main() -> None:
54-
with open("report.txt", "w") as report_file:
55-
console = Console(
56-
file=report_file,
57-
width=72,
58-
force_terminal=True,
59-
color_system="standard",
60-
)
61-
console.print(Markdown(message))
57+
file = io.StringIO()
58+
console = Console(
59+
file=file,
60+
width=72,
61+
force_terminal=True,
62+
color_system="standard",
63+
)
64+
console.print(Markdown(message))
65+
66+
string_literal = repr(file.getvalue())
67+
68+
# make single line string literal into multiline string literal
69+
if '"""' in string_literal:
70+
msg = "Error: Unexpected triple-quotes in rich output"
71+
raise AssertionError(msg)
72+
string_literal = string_literal[1:-1].replace(r"\n", "\n")
73+
string_literal = re.sub(r"[ ]+$", "", string_literal, flags=re.MULTILINE)
74+
string_literal = f'"""\n\n\n\n\n{string_literal}"""'
75+
76+
print(string_literal) # noqa: T201
6277

6378

6479
if __name__ == "__main__":

0 commit comments

Comments
 (0)