From b0f69e191c25e447a1241d5f6e5c0a1cbb629a25 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 4 May 2022 13:31:37 +0200 Subject: [PATCH 1/3] reduce heading font size within docstrings --- CHANGELOG.md | 2 ++ pdoc/templates/content.css | 23 +++++++++++++++++++++-- pdoc/templates/default/module.html.jinja2 | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c9010f5..b6e27c29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This greatly improves support for native modules where no Python source code is available, for example when using PyO3. ([#390](https://github.com/mitmproxy/pdoc/issues/390), [@mhils](https://github.com/mhils)) + - Template Style Improvements: The size of headings within docstrings has been reduced. + ([#383](https://github.com/mitmproxy/pdoc/issues/383), [@jacksund](https://github.com/jacksund) and [@mhils](https://github.com/mhils)) - Improve rendering of `typing.TypedDict` subclasses. ([#389](https://github.com/mitmproxy/pdoc/issues/389), [@mhils](https://github.com/mhils)) diff --git a/pdoc/templates/content.css b/pdoc/templates/content.css index c3d74bae..1b5cc5b9 100644 --- a/pdoc/templates/content.css +++ b/pdoc/templates/content.css @@ -79,6 +79,25 @@ This makes sure that the pdoc styling doesn't leak to the rest of the page when padding: .2em 0; } +.pdoc > section:not(.module-info) h1 { + font-size: 1.5rem; + font-weight: 500; +} +.pdoc > section:not(.module-info) h2 { + font-size: 1.4rem; + font-weight: 500; +} +.pdoc > section:not(.module-info) h3 { + font-size: 1.3rem; + font-weight: 500; +} +.pdoc > section:not(.module-info) h4 { + font-size: 1.2rem; +} +.pdoc > section:not(.module-info) h5 { + font-size: 1.1rem; +} + .pdoc a { text-decoration: none; color: var(--link); @@ -124,7 +143,7 @@ This makes sure that the pdoc styling doesn't leak to the rest of the page when padding: 0; } -.pdoc > section:not(:first-of-type) { +.pdoc > section:not(.module-info) { /* this margin should collapse with docstring margin, but not for the module docstr which is followed by view_source. */ margin-bottom: 1.5rem; @@ -180,7 +199,7 @@ This makes sure that the pdoc styling doesn't leak to the rest of the page when outline: 0; } -.pdoc > section:first-of-type details > summary { +.pdoc > section.module-info details > summary { top: -20px; } diff --git a/pdoc/templates/default/module.html.jinja2 b/pdoc/templates/default/module.html.jinja2 index 6d7096c1..26e18ed4 100644 --- a/pdoc/templates/default/module.html.jinja2 +++ b/pdoc/templates/default/module.html.jinja2 @@ -72,7 +72,7 @@ {% block content %}
{% block module_info %} -
+
{% block edit_button %} {% if edit_url %} {% if "github.com" in edit_url %} From 1896f22cad1120f4a891f760a42dabdfb619c319 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 4 May 2022 13:33:14 +0200 Subject: [PATCH 2/3] indent docstrings on desktop screens --- CHANGELOG.md | 1 + pdoc/templates/content.css | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6e27c29..247924ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ for example when using PyO3. ([#390](https://github.com/mitmproxy/pdoc/issues/390), [@mhils](https://github.com/mhils)) - Template Style Improvements: The size of headings within docstrings has been reduced. + Docstrings are now slightly indented on wide screens. ([#383](https://github.com/mitmproxy/pdoc/issues/383), [@jacksund](https://github.com/jacksund) and [@mhils](https://github.com/mhils)) - Improve rendering of `typing.TypedDict` subclasses. ([#389](https://github.com/mitmproxy/pdoc/issues/389), [@mhils](https://github.com/mhils)) diff --git a/pdoc/templates/content.css b/pdoc/templates/content.css index 1b5cc5b9..9102adaa 100644 --- a/pdoc/templates/content.css +++ b/pdoc/templates/content.css @@ -208,6 +208,10 @@ This makes sure that the pdoc styling doesn't leak to the rest of the page when margin-bottom: 1.5rem; } +.pdoc section:not(.module-info) .docstring { + margin-left: clamp(0rem, 5vw - 2rem, 1rem); +} + .pdoc .docstring .pdoc-code { margin-left: 1em; margin-right: 1em; From e9dea660dc640cc760b8d9984a079b7b5d844778 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 4 May 2022 13:33:26 +0200 Subject: [PATCH 3/3] update snapshots --- test/testdata/demo.html | 4 +- test/testdata/demo_eager.html | 4 +- test/testdata/demo_long.html | 4 +- test/testdata/demopackage.html | 4 +- test/testdata/demopackage_dir.html | 22 +-- test/testdata/example_customtemplate.html | 4 +- test/testdata/example_darkmode.html | 4 +- test/testdata/example_mkdocs.html | 4 +- test/testdata/flavors_google.html | 4 +- test/testdata/flavors_numpy.html | 4 +- test/testdata/flavors_rst.html | 4 +- test/testdata/math_demo.html | 4 +- test/testdata/misc.html | 181 ++++++++++++++++++---- test/testdata/misc.py | 32 +++- test/testdata/misc.txt | 6 +- test/testdata/misc_py310.html | 4 +- test/testdata/misc_py39.html | 4 +- test/testdata/render_options.html | 10 +- test/testdata/top_level_reimports.html | 4 +- test/testdata/type_checking_imports.html | 4 +- test/testdata/type_stub.html | 4 +- 21 files changed, 234 insertions(+), 81 deletions(-) diff --git a/test/testdata/demo.html b/test/testdata/demo.html index 64eb89ad..2b96eed4 100644 --- a/test/testdata/demo.html +++ b/test/testdata/demo.html @@ -10,7 +10,7 @@ - +
-
+

demo

diff --git a/test/testdata/demo_eager.html b/test/testdata/demo_eager.html index afef0fba..bf6e506e 100644 --- a/test/testdata/demo_eager.html +++ b/test/testdata/demo_eager.html @@ -10,7 +10,7 @@ - +
-
+

demo_eager

diff --git a/test/testdata/demo_long.html b/test/testdata/demo_long.html index 084ea0e4..ab6deeb4 100644 --- a/test/testdata/demo_long.html +++ b/test/testdata/demo_long.html @@ -10,7 +10,7 @@ - +
-
+

demo_long

diff --git a/test/testdata/demopackage.html b/test/testdata/demopackage.html index e298be47..878be2d5 100644 --- a/test/testdata/demopackage.html +++ b/test/testdata/demopackage.html @@ -10,7 +10,7 @@ - +
-
+

demopackage

diff --git a/test/testdata/demopackage_dir.html b/test/testdata/demopackage_dir.html index a675cf51..51087cf0 100644 --- a/test/testdata/demopackage_dir.html +++ b/test/testdata/demopackage_dir.html @@ -63,7 +63,7 @@

index.html

- + @@ -282,7 +282,7 @@

demopackage2.html

- +
-
+

demopackage2

@@ -524,7 +524,7 @@

demopackage.html

- +
-
+
Edit on GitHub

demopackage

@@ -1027,7 +1027,7 @@

demopackage/child_c.html

- +
-
+
Edit Source

demopackage.child_c

@@ -1354,7 +1354,7 @@

demopackage/child_b.html

- +
-
+
Edit on GitLab

demopackage.child_b

@@ -1696,7 +1696,7 @@

demopackage/_child_e.html

- +
-
+
Edit on GitHub

demopackage._child_e

diff --git a/test/testdata/example_customtemplate.html b/test/testdata/example_customtemplate.html index 665a9b04..7e260ef4 100644 --- a/test/testdata/example_customtemplate.html +++ b/test/testdata/example_customtemplate.html @@ -11,7 +11,7 @@ - +
-
+

demo

diff --git a/test/testdata/example_darkmode.html b/test/testdata/example_darkmode.html index 6eeb46a7..dd3d4203 100644 --- a/test/testdata/example_darkmode.html +++ b/test/testdata/example_darkmode.html @@ -10,7 +10,7 @@ - +
-
+

demo

diff --git a/test/testdata/example_mkdocs.html b/test/testdata/example_mkdocs.html index 7b3c1d70..338cc854 100644 --- a/test/testdata/example_mkdocs.html +++ b/test/testdata/example_mkdocs.html @@ -4,7 +4,7 @@
-
+

demo

@@ -142,4 +142,4 @@

-

\ No newline at end of file + \ No newline at end of file diff --git a/test/testdata/flavors_google.html b/test/testdata/flavors_google.html index 810fdb4b..67308fd5 100644 --- a/test/testdata/flavors_google.html +++ b/test/testdata/flavors_google.html @@ -10,7 +10,7 @@ - +
-
+

flavors_google

diff --git a/test/testdata/flavors_numpy.html b/test/testdata/flavors_numpy.html index 914443e6..e6afe77e 100644 --- a/test/testdata/flavors_numpy.html +++ b/test/testdata/flavors_numpy.html @@ -10,7 +10,7 @@ - +
-
+

flavors_numpy

diff --git a/test/testdata/flavors_rst.html b/test/testdata/flavors_rst.html index 2cc82a0f..135145f7 100644 --- a/test/testdata/flavors_rst.html +++ b/test/testdata/flavors_rst.html @@ -10,7 +10,7 @@ - +
-
+

flavors_rst

diff --git a/test/testdata/math_demo.html b/test/testdata/math_demo.html index a86ea0c4..27d6d3f1 100644 --- a/test/testdata/math_demo.html +++ b/test/testdata/math_demo.html @@ -10,7 +10,7 @@ - +