Skip to content

Commit 726d965

Browse files
authored
Merge branch 'master' into header-dropdown
2 parents 40acb52 + 8a24592 commit 726d965

File tree

8 files changed

+66
-129
lines changed

8 files changed

+66
-129
lines changed

docs/_static/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:root {
2+
--sd-color-primary: #f37726;
3+
}

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"sphinxcontrib.youtube",
2727
"sphinx_copybutton",
2828
"sphinx_design",
29+
"sphinx_examples",
2930
"sphinx_tabs.tabs",
3031
"sphinx_thebe",
3132
"sphinx_togglebutton",
@@ -96,6 +97,7 @@
9697
# relative to this directory. They are copied after the builtin static files,
9798
# so a file named "default.css" will overwrite the builtin "default.css".
9899
html_static_path = ["_static"]
100+
html_css_files = ["custom.css"]
99101
jupyter_execute_notebooks = "cache"
100102
thebe_config = {
101103
"repository_url": "https://github.com/binder-examples/jupyter-stacks-datascience",

docs/content-blocks.md

Lines changed: 53 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@ There are a few content blocks that are unique to this theme.
2121

2222
Here is what quotations and epigraphs look like in `sphinx-book-theme`:
2323

24-
A quote with no attribution:
25-
24+
```{example} Default markdown quotes
2625
> Here's my quote, it's pretty neat.
2726
> I wonder how many lines I can create with
2827
> a single stream-of-consciousness quote.
2928
> I could try to add a list of ideas to talk about.
3029
> I suppose I could just keep going on forever,
3130
> but I'll stop here.
31+
```
3232

3333
Sometimes you'd like to draw more attention to a quote. To do so, use the `{epigraph}` directive.
3434
Below is an epigraph, click the button to the right of it to show the code that was used
3535
to generate it:
3636

37+
````{example} A basic epigraph
3738
```{epigraph}
3839
Here's my quote, it's pretty neat.
3940
I wonder how many lines I can create with
@@ -42,36 +43,12 @@ I could try to add a list of ideas to talk about.
4243
I suppose I could just keep going on forever,
4344
but I'll stop here.
4445
```
45-
46-
`````{toggle}
4746
````
48-
```{epigraph}
49-
Here's my quote, it's pretty neat.
50-
I wonder how many lines I can create with
51-
a single stream-of-consciousness quote.
52-
I could try to add a list of ideas to talk about.
53-
I suppose I could just keep going on forever,
54-
but I'll stop here.
55-
```
56-
````
57-
`````
5847

5948
You can also add an attribution to epigraphs by adding a blank line,
6049
followed by a line that starts with `--`. This will be renderered like so:
6150

62-
```{epigraph}
63-
Here's my quote, it's pretty neat.
64-
I wonder how many lines I can create with
65-
a single stream-of-consciousness quote.
66-
I could try to add a list of ideas to talk about.
67-
I suppose I could just keep going on forever,
68-
but I'll stop here.
69-
70-
-- Jo the Jovyan, *[the jupyter book docs](https://jupyterbook.org)*
71-
```
72-
73-
`````{toggle}
74-
````
51+
````{example} Epigraphs with attribution
7552
```{epigraph}
7653
Here's my quote, it's pretty neat.
7754
I wonder how many lines I can create with
@@ -83,65 +60,49 @@ but I'll stop here.
8360
-- Jo the Jovyan, *[the jupyter book docs](https://jupyterbook.org)*
8461
```
8562
````
86-
`````
8763

88-
## Sidebars
89-
90-
There are two different kinds of sidebar-like content in `sphinx-book-theme`,
91-
typical `{sidebar}` directives, as well as a theme-specific `{margin}` directive.
92-
This section covers both. Both allow you to place extra content
93-
separately from your main content.
94-
95-
```{tip}
96-
Sidebar content will generally overlap with the white space where your site's
97-
table of contents lives. When the reader scrolls sidebar content into view, the
98-
right TOC should hide itself automatically.
99-
```
100-
101-
### Margin content
64+
## Margin content
10265

10366
You can specify content that should exist in the right margin. This will behave
10467
like a regular sidebar until the screen hits a certain width, at which point this
10568
content will "pop out" to the right white space.
10669

10770
There are two ways to add content to the margin: via the `{margin}` directive, and via adding CSS classes to your own content.
10871

109-
#### Use a `{margin}` directive to add margin content
72+
### Use a `{margin}` directive to add margin content
11073

11174
The `{margin}` directive allows you to create margin content with your own title and content block.
11275
It is a wrapper around the Sphinx `{sidebar}` directive, and largely does its magic via CSS classes (see below).
11376

11477
Here's how you can use the `{margin}` directive:
11578

79+
````{example}
80+
:no-container:
81+
:reverse:
82+
11683
```{margin} **Here is my margin content**
11784
It is pretty cool!
11885
```
119-
120-
````
121-
```{margin} **My margin title**
122-
Here is my margin content, it is pretty cool!
123-
```
12486
````
12587

126-
#### Use CSS classes to add margin content
88+
### Use CSS classes to add margin content
12789

12890
You may also directly add CSS classes to elements on your page in order to make them behave like margin content.
12991
To do so, add the `margin` CSS class to any element on the page.
13092
Many Sphinx directives allow you to directly add classes.
13193
For example, here's the syntax to add a `margin` class to a `{note}` directive:
13294

133-
:::{note}
134-
:class: margin
135-
This note will be in the margin!
136-
:::
95+
```{example}
96+
:no-container:
97+
:reverse:
13798
138-
```
13999
:::{note}
140100
:class: margin
141101
This note will be in the margin!
142102
:::
143103
```
144104

105+
145106
This works for most elements on the page, but in general this works best for "parent containers" that are the top-most element of a bundle of content.
146107

147108
For example, we can even put a whole figure in the margin like so:
@@ -151,16 +112,10 @@ You can also put the whole figure in the margin if you like.
151112
Here is a figure with a caption below. We'll add a note below to create
152113
some vertical space to see better.
153114

154-
```{figure} images/cool.jpg
155-
---
156-
figclass: margin
157-
alt: My figure text
158-
name: myfig4
159-
---
160-
And here is my figure caption
161-
```
115+
````{example}
116+
:no-container:
117+
:reverse:
162118
163-
````
164119
```{figure} images/cool.jpg
165120
---
166121
figclass: margin
@@ -174,118 +129,94 @@ And here is my figure caption
174129
We can reference the figure with {ref}`myfig4`. Or a numbered reference like
175130
{numref}`myfig4`.
176131

177-
#### Figure captions in the margin
132+
### Figure captions in the margin
178133

179134
You can configure figures to use the margin for captions.
180135
Here is a figure with a caption to the right.
181136

182-
```{figure} images/cool.jpg
183-
---
184-
width: 60%
185-
figclass: margin-caption
186-
alt: My figure text
187-
name: myfig5
188-
---
189-
And here is my figure caption, if you look to the left, you can see that COOL is in big red letters. But you probably already noticed that, really I am just taking up space to see how the margin caption looks like when it is really long :-).
190-
```
137+
````{example}
138+
:no-container:
139+
:reverse:
191140
192-
And the text that produced it:
193-
194-
````
195141
```{figure} images/cool.jpg
196142
---
197143
width: 60%
198144
figclass: margin-caption
199145
alt: My figure text
200146
name: myfig5
201147
---
202-
And here is my figure caption, if you look to the left, you can see that COOL is in big red letters. But you probably already noticed that, really I am just taking up space to see how the margin caption looks like when it is really long :-)
148+
And here is my figure caption, if you look to the left, you can see that COOL is in big red letters. But you probably already noticed that, really I am just taking up space to see how the margin caption looks like when it is really long :-).
203149
```
204150
````
205151

206152
We can reference the figure with {ref}`this reference <myfig5>`. Or a numbered reference like
207153
{numref}`myfig5`.
208154

209-
### Content sidebars
155+
### Examples of margin content
210156

211-
Content sidebars exist in-line with your text, but allow the rest of the
212-
page to flow around them, rather than moving to the right margin.
213-
To add content sidebars, use this syntax:
157+
There are many kinds of content you can put in the margin, here are some examples.
214158

215-
````{sidebar} **My sidebar title**
216-
```{note}
217-
Here is my sidebar content, it is pretty cool!
218-
```
219-
![](images/cool.jpg)
220-
````
221-
222-
Note how the content wraps around the sidebar to the right.
223-
However, the sidebar text will still be in line with your content. There are
224-
certain kinds of elements, such as "note" blocks and code cells, that may
225-
clash with your sidebar. If this happens, try using a `{margin}` instead.
226-
227-
````
228-
```{sidebar} **My sidebar title**
229-
Here is my sidebar content, it is pretty cool!
230-
```
231-
````
232-
233-
### Adding content to margins and sidebars
234-
235-
Sidebar/margin content can include all kinds of things, such as code blocks:
236-
237-
````{margin} Code blocks in margins
238-
```python
239-
print("here is some python")
240-
```
241-
````
159+
`````{example} Code blocks in the margin
160+
:no-container:
161+
:reverse:
242162
243-
`````
244163
````{margin} Code blocks in margins
245164
```python
246165
print("here is some python")
247166
```
248167
````
249168
`````
250169

251-
as well as admonitions and images:
170+
`````{example} Admonitions and images in the margin
171+
:no-container:
172+
:reverse:
252173
253174
````{margin} **Notes in margins**
254175
```{note}
255176
Wow, a note with an image in a margin!
256177
![](images/cool.jpg)
257178
```
258179
````
259-
260180
`````
261-
````{margin} **Notes in margins**
181+
182+
## Sidebars
183+
184+
Sidebars exist in-line with your text, but allow the rest of the
185+
page to flow around them, rather than moving to the right margin.
186+
187+
To add content sidebars, use this syntax:
188+
189+
`````{example}
190+
:no-container:
191+
192+
````{sidebar} **My sidebar title**
262193
```{note}
263-
Wow, a note with an image in a margin!
264-
![](images/cool.jpg)
194+
Here is my sidebar content, it is pretty cool!
265195
```
196+
![](images/cool.jpg)
266197
````
267198
`````
268199

200+
Note how the content wraps around the sidebar to the right.
201+
However, the sidebar text will still be in line with your content. There are
202+
certain kinds of elements, such as "note" blocks and code cells, that may
203+
clash with your sidebar. If this happens, try using a `{margin}` instead.
204+
269205
## Full-width content
270206

271207
Full-width content extends into the right margin, making it stand out against
272208
the rest of your book's content. To add full-width content to your page, add the
273209
class `full-width` to any of the elements in your documentation. For example, you can
274210
add a `full-width` tag to a note element like this:
275211

276-
````
277-
```{note}
278-
:class: full-width
279-
This content will be full-width
280-
```
281-
````
282-
283-
This code results in the following output:
212+
````{example}
213+
:no-container:
284214
285215
```{note}
286216
:class: full-width
287217
This content will be full-width
288218
```
219+
````
289220

290221
```{admonition} A note for ipynb users
291222
If you are using a Jupyter Notebook as inputs to your documentation using the

docs/reference/extensions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,7 @@ This toggle is in the margin!
108108

109109
```{youtube} 2Z7wDaYt53Y
110110
```
111+
112+
## `sphinx-design` for UI components
113+
114+
{bdg-primary}`Test badge`.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ doc = [
6060
"plotly",
6161
"sphinx~=4.0", # Force Sphinx to be the latest version
6262
"sphinx-design",
63+
"sphinx-examples",
6364
"sphinx-copybutton",
6465
"sphinx-tabs",
6566
"sphinx-togglebutton>=0.2.1",

src/sphinx_book_theme/assets/styles/components/_search.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Search bar and text styling from searches *
33
*********************************************/
44

5-
// Highlight search phrases
5+
// Highlighted search items are a slightly lighter version of Jupyter orange
66
dt:target,
77
span.highlighted {
8-
background-color: #fbe54e;
8+
background-color: #f3772642;
99
}

src/sphinx_book_theme/assets/styles/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
// Re-usable components across the theme
3131
@import "components/buttons";
32+
@import "components/search.scss";
3233

3334
// Content blocks in standard Sphinx
3435
@import "content/admonitions";

src/sphinx_book_theme/assets/styles/pages/_search.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,5 @@ ul.search {
4444
color: $grey--medium;
4545
}
4646
}
47-
48-
// Highlighted search items are a slightly lighter version of Jupyter orange
49-
span.highlighted {
50-
background-color: #f3772642;
51-
}
5247
}
5348
}

0 commit comments

Comments
 (0)