qiime2 / cancer-microbiome-intervention-tutorial

JupyterBook for QIIME 2 FAES January 2022 workshop
Other
11 stars 15 forks source link

add custom `question` admonition #24

Closed gregcaporaso closed 2 years ago

gregcaporaso commented 2 years ago

I'm adding some admonition blocks through-out that pose questions to the user. I'm defining these as class question, but since that's not define they just show up as generic admonitions. We should define question as a custom admonition so we can style it different - for example, a question mark on the left side of the admonition box.

I'm also using the dropdown class for these so the answer can be hidden from the user as they work through the tutorial. For example:

Screen Shot 2021-12-20 at 6 28 27 PM Screen Shot 2021-12-20 at 6 28 52 PM

The source for this looks like the following:

````{admonition} Try summarizing the feature table that was created by this round of filtering. Expand this box if you need help. 
:class: question, dropdown

```{usage}
use.action(
    use.UsageAction(plugin_id='feature_table', action_id='summarize'),
    use.UsageInputs(table=filtered_table_4, sample_metadata=sample_metadata),
    use.UsageOutputNames(visualization='filtered_table_4_summ'),
)

One issue is that I don't think I can split the first line (the question) across multiple lines in the source or it will put the second and all remaining lines in the body of the admonition block rather than the header. If we could handle that with the custom admonition (if there isn't another way) that'd be pretty handy too.

thermokarst commented 2 years ago

Have you tested out the q2doc.question directive defined in sphinx-ext-qiime2? If so, does it not apply the correct styling?

gregcaporaso commented 2 years ago

I hadn't, thanks for the reminder, forget we had that defined already. Trying to get it working on this JB but haven't yet. Not sure what I'm doing wrong (code is here) - will try more tomorrow.

thermokarst commented 2 years ago

I played with this a bit this morning, I don't think the q2doc.question directive will work as-is here. Sounds like we should just add some custom CSS to match the question class you're using here, and call it a day: https://jupyterbook.org/advanced/html.html#an-example-custom-admonitions

gregcaporaso commented 2 years ago

Sounds like a plan, thanks for looking into it. I'm going to revert my change to _config.yml and continue to just use question as my admonition class. If someone can add the CSS for this, that would be great.

thermokarst commented 2 years ago

What if we used this ebp extension, instead? https://ebp-sphinx-exercise.readthedocs.io/en/latest/syntax.html

gregcaporaso commented 2 years ago

Love it! :100:

thermokarst commented 2 years ago

Documenting here, a really easy way around the long-line issue in the admonition title is to use a JB substitution variable:

https://jupyterbook.org/content/content-blocks.html#substitutions-and-variables-in-markdown

image image

gregcaporaso commented 2 years ago

Confirming that substitutions worked for the long-line issue (added in #42)- thanks @thermokarst!