Skip to content
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

DOCS: admonition customization #1155

Merged
merged 5 commits into from
Feb 13, 2023
Merged

DOCS: admonition customization #1155

merged 5 commits into from
Feb 13, 2023

Conversation

12rambau
Copy link
Collaborator

@12rambau 12rambau commented Feb 5, 2023

Fix #1124

first draft of an extra documentation page to explain how to create a custom admonition using our theme and 1 extra extention.

That's a draft so feel free to change anything in the text, I'm not the best when it comes to explain stuff.

@12rambau 12rambau marked this pull request as ready for review February 5, 2023 16:55
@drammock
Copy link
Collaborator

drammock commented Feb 7, 2023

I reworked the new docs page a bit. I think the prose flow is better now, but I also did a bold move that maybe you won't like: I removed all the repetition between the rendered admonitions and the code examples. Now, the code examples are auto-inserted using .. include:: with :start-after: and :end-before: tags to insert parts of the file back into itself. Same strategy is used to insert the actual CSS rules into the CSS tabs. This mostly works as expected, and is IMO better because there's no risk of the rendered admonition and the example code becoming out-of-sync. The problems:

  1. there is an (unavoidable?) newline at the start of the rST example code blocks.
  2. the syntax highlighting is wrong because when using .. include it apparently doesn't parse the input, even if you specify :code: css or :code: rst or whatever. As a result, the relevant div gets a highlight-default class instead of highlight-css or highlight-rst.
    • You'll see that I tried to hack it to add this class, but that didn't work either because (1) the highlight-default class comes later in the class list, and (2) because the code wasn't parsed as CSS, the pygments inline span classes are wrong/simplified.

I'm 50/50 on whether the advantages outweigh the disadvantages here. WDYT?

@drammock
Copy link
Collaborator

drammock commented Feb 7, 2023

@12rambau
Copy link
Collaborator Author

12rambau commented Feb 7, 2023

Thank you very much for revamping everything, the new wording is way better. I love the way you're using incude. For rst that's not a problem at all but css is barely readable. let's give us 1-2 days to find a solution and if it's not possible we can still go back to hard coding them.

@drammock
Copy link
Collaborator

drammock commented Feb 9, 2023

OK I think this is not anything we can fix, it needs upstream. Here is the MWE:

https://dan.mccloy.info/data/sphinx-include-highlight-mwe/

and the rST source of that page:

https://dan.mccloy.info/data/sphinx-include-highlight-mwe/_sources/index.rst.txt

@drammock
Copy link
Collaborator

drammock commented Feb 9, 2023

crossref to upstream bug report: sphinx-doc/sphinx#11185

docs/_static/custom.css Outdated Show resolved Hide resolved
@@ -52,6 +52,6 @@ div.admonition.admonition-youtube > .admonition-title:before {
}
div.admonition.admonition-youtube > .admonition-title:after {
color: #ff0000;
content: "\f26c"; /* fa-brands fa-tv */
content: "\f26c"; /* fa-solid fa-tv */
Copy link
Collaborator

@drammock drammock Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@12rambau any reason you picked f26c here instead of f167?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the youtube icon is a brand icon, if you want to use it you also need to customize the font-family from "Font Awesome 6 Free" to "Font Awesome 6 Brands".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, so the brand icons don't work easily in an admonition? I didn't realize that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope it doesn't, I saw it, tried to find an easy fix and realize we need to update fa font management first so I keep it in my mind and if someone complains about it I'll work on it but that's low priority I think

Copy link
Collaborator

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, IMO we should get it merged because it is a helpful improvement even if there are still things to improve!

One quick comment in there about a little sphinx package I wrote that might be useful...but I don't think it needs to block


Here we demonstrate an admonition with a custom icon, color, and title (and also make it collapsible). Note that the multiple admonition class names are space-separated:

.. begin-example-youtube
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually created a tiny little sphinx extension to show off syntax examples, maybe it would be useful here?

https://ebp-sphinx-examples.readthedocs.io/en/latest/

It gives you an example directive like:

```{example}
**foo**
```

And it create a little preview + the raw syntax to show how to make the preview.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be perfect but you can't display 2 files yet right (like in these examples css + rst) ?

I will merge it and we'll see how to use it in the upcoming future

@12rambau 12rambau merged commit 121873d into pydata:main Feb 13, 2023
@12rambau 12rambau deleted the admonition branch February 13, 2023 09:32
12rambau added a commit to 12rambau/pydata-sphinx-theme that referenced this pull request Mar 2, 2023
* Fix extra whitespace in sidebars (pydata#1115)

* Fix extra whitespace in sidebars

* Searchbox

* Update src/pydata_sphinx_theme/__init__.py

Co-authored-by: Daniel McCloy <[email protected]>

* make test pass

* Fix template filter to remove empty files

* ABlog in template test

* Move clear search button to primary sidebar

* Move search clear button to top of article

Co-authored-by: Daniel McCloy <[email protected]>

* FIX: Use logo_url instead deprecated logo in theme (pydata#1094) (pydata#1097)

resolves pydata#1094

* ENH/MAINT: avoid overwriting the HtmlTranslator (pydata#1105)

Co-authored-by: Chris Holdgraf <[email protected]>
Fix pydata#143
Fix pydata#94

* fix: align sidebar sliding with the buttons (pydata#1123)

* fix: aline the sidebar sliding with the buttons

* build: force test to run on all platform
if one platform is failing we cannot see if it's platform related as the other were closed

* fix: use correct path for documentation logo

* MAINT: Improve font sizing (pydata#1129)

Fix pydata#1001

* MAINT: Refactor workflows to reduce test dependencies (pydata#1136)

* MAINT: update prerelease workflow (pydata#1140)

* ABlog: Updates for new HTML structure (pydata#1118)

* ABlog: Updates for new HTML structure

* Update templates for latest release

* Bump to dev0

* Standardize logo image behavior between Sphinx and this theme (pydata#1132)

Co-authored-by: Daniel McCloy <[email protected]>
Co-authored-by: Chris Holdgraf <[email protected]>
Co-authored-by: Chris Holdgraf <[email protected]>

* 0.13.0rc1

* Build(deps): Bump http-cache-semantics from 4.1.0 to 4.1.1 (pydata#1154)

* DOC: Use only shield.io for badges in README (pydata#1152)

* Copyright semicolon (pydata#1160)

* FIX: Flex behavior should shrink header items instead of brand (pydata#1158)

Co-authored-by: Chris Holdgraf <[email protected]>
Fixes pydata#1143

* STYLE: lint the documentation with Doc8 (pydata#1150)

Fix pydata#1139

* Add test for internationalization and translations (pydata#1138)

* FIX: Javascript incorrect check for variable (pydata#1166)

* MAINT: update pypi classifiers (pydata#1153)

Fix pydata#1106

* remove emoji from landing page (pydata#1151)

* add fa icons instead of emoji

* remove fix for emojis

* use markup for readme emojis

* use pst-color-primary instead of sd-text-primary

* make our semantic colors available as classes

* try again

---------

Co-authored-by: Daniel McCloy <[email protected]>

* FIX: Narrow scope of style rule for GitHub & GitLab link shortening (pydata#1167)

Fixes pydata#1156

* ENH: Add breadcrumbs to article header (pydata#1142)

* ENH: Add breadcrumbs to article header

* Update src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html

Co-authored-by: Tania Allard <[email protected]>

* More fixes

* Improving nested page behavior

* Documenting breadcrumbs

* Update src/pydata_sphinx_theme/assets/styles/components/_breadcrumbs.scss

Co-authored-by: Rambaud Pierrick <[email protected]>

* Breacrumbs have link color

---------

Co-authored-by: Tania Allard <[email protected]>
Co-authored-by: Rambaud Pierrick <[email protected]>

* Degrade gracefully when JavaScript is disabled (pydata#1146)

* Fix header vertical spacing and jupyter-sphinx cells (pydata#1164)

Fixes undefined

* RLS: v0.13.0rc2 (pydata#1170)

* DOCS: admonition customization (pydata#1155)

* first draft of the admonition customization

* typo in doc link

* flesh out admon. customization example; DRY

* use :code:rst instead of :literal:

* Update docs/_static/custom.css

---------

Co-authored-by: Daniel McCloy <[email protected]>

* Fix article header CSS (pydata#1171)

* “Edit this page” → “Edit on GitHub/GitLab/Bitbucket” (pydata#1177)

* “Edit this page” → “Edit on GitHub/GitLab/Bitbucket”

Fixes pydata#1172

* Add tests

* Fix typo

* Properly handle default_mode=auto when writing logos (pydata#1183)

We used to only defaulting to the light version when `default_mode` was
undefined, not when it was explicitly set to `auto`. We also need to
handle the latter, as the new test shows.

Closes pydata#1180

Co-authored-by: Jérémy Bobbio (Lunar) <[email protected]>

* fix: correctly add DOM listeners (pydata#1179)

fix adding DOM listeners

* maint: update GitLab URL tests (pydata#1186)

Co-authored-by: JoerivanEngelen <[email protected]>

* Standardize template structure in more sections (pydata#1184)

* Standardize template structure in all sections

* Fixing footer behavior

* Update docs/user_guide/layout.rst

Co-authored-by: Daniel McCloy <[email protected]>

* Remove use of id= as much as possible

---------

Co-authored-by: Daniel McCloy <[email protected]>

* maint: remove sphinx-panels support; remove deprecated config shims (pydata#1188)

* Minor style improvements to ablog (pydata#1185)

* RLS: v0.13.0rc3

* dev0

* FIX: Some style bugs (pydata#1191)

* FIX: Some style bugs

* Move link word wrap to global rule

* DOCS: Add internationalization instructions (pydata#1178)

Co-authored-by: James McKinney <[email protected]>

* Refactor contributing docs to be more modular (pydata#1173)

* Dev0

* Fix github gitlab brand (pydata#1194)

* RLS: v0.13.0rc4

* FIX: Make wide equations scroll (pydata#1196)

* Fix math scrollbars for realz (pydata#1198)

* Fix math scrollbars for realz

* Update src/pydata_sphinx_theme/assets/styles/content/_math.scss

* Update src/pydata_sphinx_theme/assets/styles/content/_math.scss

* copy_logo_images: do not render dynamic Sphinx template content (pydata#1204)

* copy_logo_images: do not render dynamic Sphinx template content when copying logo image files

* Update src/pydata_sphinx_theme/__init__.py

---------

Co-authored-by: Chris Holdgraf <[email protected]>

* Add conditional check for last-updated template (pydata#1201)

* Add conditional check for last-updated template

* Whitespace

* Properly set configuration with app.builder.theme_options (pydata#1199)

* Properly set configuration

* Dict to values

* Making it explicit in a function

* Better name

* Fix test

* Foot

* Revert complex config set

* Clarify docs

* Use CSS transform for skip link (pydata#1206)

* feat: Add full i18n support (pydata#1192)

Co-authored-by: Daniel McCloy <[email protected]>
Co-authored-by: James McKinney <[email protected]>
Co-authored-by: Chris Holdgraf <[email protected]>
Co-authored-by: Chris Holdgraf <[email protected]>

* Dev0

* FIX: Remove icon links component when no icon links given (pydata#1209)

* RLS: 0.13.0rc5

* dev0

* FIX: Get theme options in a more robust way (pydata#1214)

* RLS: v0.13.0rc6

* Make heading-style use the font-weight-heading value (pydata#1213)

* Make heading-style use the font-weight-heading value

* Separate font-weight setting for content headers and admonitions

* Flip var to be consistent with --pst-font-weight-heading instead

* RLS: v0.13.0

* bump: dev0

* DOCS: Remove <p> from announcement sample text (pydata#1223)

---------

Co-authored-by: Chris Holdgraf <[email protected]>
Co-authored-by: Daniel McCloy <[email protected]>
Co-authored-by: Nico Albers <[email protected]>
Co-authored-by: Chris Holdgraf <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brendan Heberlein <[email protected]>
Co-authored-by: Tania Allard <[email protected]>
Co-authored-by: Lunar <[email protected]>
Co-authored-by: Jean Abou-Samra <[email protected]>
Co-authored-by: Jérémy Bobbio (Lunar) <[email protected]>
Co-authored-by: JoerivanEngelen <[email protected]>
Co-authored-by: James McKinney <[email protected]>
Co-authored-by: James Addison <[email protected]>
Co-authored-by: Veronica Berglyd Olsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add custom and collapsible admonition functionality
3 participants