Open rodrigogiraoserrao opened 1 year ago
Default css is not a bad idea. Could be very useful in docs.
Default css is not a bad idea. Could be very useful in docs.
Yup. That was more of a rhetoric question so that I wouldn't forget about it. The default css should definitely be documented but the only obvious alternative I know of would make the full string appear inlined with the attribute in the header... Which is not what we want.
With the plugin we could inject it into the docstring and surrounded by backticks to style it as Textual CSS.
For widgets, can we collect all the attributes that are reactive and list them in a separate table? E.g., to include them in the reference pages.
OK, so I wrote a hack with tree_sitter and can parse out CSS_DEFAULTS from Python, then parse it as a CSS language.
Now what?
Consider this rule:
DataTable {
background: $surface ;
color: $text;
height: auto;
max-height: 100%;
}
DataTable:dark
and DataTable > .datatable--even-row
, how should it be displayed?height: auto
means the same regardless of the widget, and it has a meaning distinct from leaving height blank. There are some words, like .datatable--even-row
that are unique to one widget. So links and hover text in a big config file?# Styling for zebra strips\nDataTable > .datatable--even-row {...
?DataTable > .datatable--even-row {
background: $primary 10%;
}
gives {"DataTable > .datatable--even-row": {"background": ["$primary", "10%"]}
Outside of DEFAULT_CSS, what else should get parsed?
Just as an FYI. I'm still playing with this:
!important
, or nests more than three levels. A small, enumerated number of Pseudo-classes are used, but not pseudo-attributes. CSS keeps adding new pseudo-classes, e.g., nth-child(3)
which Textual does not support.If anyone wishes, I can post the code so far (tools/widget_walk.py and tools/test_widget_walk*).
A widget's
BINDINGS
andCOMPONENT_CLASSES
have tables that are partially generated bytools/widget_documentation.py
but that must be kept updated by hand.Investigate whether we can make a
mkdocs
/mkdocstrings
plugin that inspects attributes likeBINDINGS
andCOMPONENT_CLASSES
to build their tables on the fly.What about
DEFAULT_CSS
? Can we document their values (e.g., by setting the docstring to match the string value itself)?