-
Notifications
You must be signed in to change notification settings - Fork 24
feat: place description line just below title (and above signature block) #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: place description line just below title (and above signature block) #405
Conversation
|
Thanks so much for taking the time to submit this. I personally think that using the "short summary" as a description under the title is a nice design. I think one of the challenges here is that the concept of a short summary might be numpydoc specific. For example, I don't think the short summary is explicitly represented in griffe. from quartodoc import preview
from griffe import Docstring, Parser
from quartodoc.parsers import get_parser_defaults
doc = """I am the short summary.
I am the extended summary. I am encouraged to be longer.
Examples
--------
abc
"""
docstring = Docstring(value=doc, parser=Parser.numpy, parser_options=get_parser_defaults("numpy"))
preview(docstring)
Notice that the short summary and extended summary are represented as a single DocstringSectionText node. titles in R vs Python docsI know the design of putting the description under the title is very R pkgdown. However, I wonder if the concept of title is modeled a bit more explicitly in roxygen2? That said, we do already pull out the first sentence of docs (e.g. basically the short summary) to use in the index:
|
|
@gadenbuie wdyt of putting the description just below the title?! I feel like you've got a good eye for this stuff! |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #405 +/- ##
==========================================
+ Coverage 88.86% 88.94% +0.07%
==========================================
Files 40 40
Lines 3027 3121 +94
==========================================
+ Hits 2690 2776 +86
- Misses 337 345 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@machow I think the short summary is standard, and described/recommended in a docstrings-related PEP (can't remember all the PEP numbers hehe). I'm totally open to add a |


This PR includes a new option (
desc_first) that reorders the docs output so as to place the first paragraph of a docstring (taken as the the description) between the title and object signature. I think by doing so, it makes it easier for readers to quickly understand what a function/class does before going into the details.So with
desc_first: true, this is the revised order:The default behavior (
desc_first=False) is unchanged, so this is backwards compatible.I used this branch to render the Great Tables docs to ensure it looks visually correct: https://pr-790--gt-python.netlify.app/reference/gt.tab_header#great_tables.GT.tab_header
Here's how it looks:
Before the change:
The following inline styles are used for the description line:
I added a few tests in
test_renderers.py.