Skip to content

Commit c95f700

Browse files
committed
Factor out boilerplate sessions
1 parent ad1d0d7 commit c95f700

6 files changed

Lines changed: 43 additions & 86 deletions

File tree

BUILD.bazel

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ py_binary(
3131
"mkdocs.yml",
3232
":au_all_units_hh",
3333
":au_all_units_noio_hh",
34+
":au_all_units_stdformat_hh",
35+
":au_all_units_stdformat_noio_hh",
3436
":au_hh",
3537
":au_noio_hh",
3638
":au_stdformat_hh",
3739
":au_stdformat_noio_hh",
38-
":au_all_units_stdformat_hh",
39-
":au_all_units_stdformat_noio_hh",
40-
] + glob(["docs/**"]),
40+
] + glob([
41+
"docs/**",
42+
"doc_snippets/**",
43+
]),
4144
deps = [
4245
requirement("mkdocs"),
4346
requirement("mkdocs-material"),
@@ -51,13 +54,16 @@ py_binary(
5154
"mkdocs.yml",
5255
":au_all_units_hh",
5356
":au_all_units_noio_hh",
57+
":au_all_units_stdformat_hh",
58+
":au_all_units_stdformat_noio_hh",
5459
":au_hh",
5560
":au_noio_hh",
5661
":au_stdformat_hh",
5762
":au_stdformat_noio_hh",
58-
":au_all_units_stdformat_hh",
59-
":au_all_units_stdformat_noio_hh",
60-
] + glob(["docs/**"]),
63+
] + glob([
64+
"docs/**",
65+
"doc_snippets/**",
66+
]),
6167
main = "mike_bin.py",
6268
deps = [
6369
":update_docs",

doc_snippets/lifetime-risk-lazy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
!!! warning "Lifetime risk"
2+
This operation is **lazy**: its result is an expression template, which refers to its operands
3+
instead of owning its own copy of the data. The result is valid only as long as its operands
4+
are alive. If it needs to outlive them, materialize it with [`eval()`](./eigen.md#eval). See
5+
our [Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
!!! warning "Lifetime risk"
2+
If the result of this operation is an Eigen expression template, it refers to its operands
3+
instead of owning its own copy of the data. The result is valid only as long as its operands
4+
are alive. If it needs to outlive them, materialize it with [`eval()`](./eigen.md#eval). See
5+
our [Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.

docs/reference/eigen.md

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,7 @@ template <typename V, typename U, typename R>
186186
auto cross(const V &a, const Quantity<U, R> &b);
187187
```
188188

189-
!!! warning "Lifetime risk"
190-
This operation is **lazy**: its result is an expression template, which refers to its operands
191-
instead of owning its own copy of the data. The result is valid only as long as its operands
192-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
193-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
189+
--8<-- "lifetime-risk-lazy.md"
194190

195191
### `normalized`
196192

@@ -225,11 +221,7 @@ template <typename V, typename U, typename R>
225221
auto cwiseProduct(const V &a, const Quantity<U, R> &b);
226222
```
227223

228-
!!! warning "Lifetime risk"
229-
This operation is **lazy**: its result is an expression template, which refers to its operands
230-
instead of owning its own copy of the data. The result is valid only as long as its operands
231-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
232-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
224+
--8<-- "lifetime-risk-lazy.md"
233225

234226
### `cwiseQuotient`
235227

@@ -249,11 +241,7 @@ template <typename V, typename U, typename R>
249241
auto cwiseQuotient(const V &a, const Quantity<U, R> &b);
250242
```
251243
252-
!!! warning "Lifetime risk"
253-
This operation is **lazy**: its result is an expression template, which refers to its operands
254-
instead of owning its own copy of the data. The result is valid only as long as its operands
255-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
256-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
244+
--8<-- "lifetime-risk-lazy.md"
257245
258246
### `cwiseAbs`
259247
@@ -264,11 +252,7 @@ template <typename U, typename R>
264252
auto cwiseAbs(const Quantity<U, R> &q);
265253
```
266254

267-
!!! warning "Lifetime risk"
268-
This operation is **lazy**: its result is an expression template, which refers to its operands
269-
instead of owning its own copy of the data. The result is valid only as long as its operands
270-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
271-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
255+
--8<-- "lifetime-risk-lazy.md"
272256

273257
### `cwiseSqrt`
274258

@@ -279,11 +263,7 @@ template <typename U, typename R>
279263
auto cwiseSqrt(const Quantity<U, R> &q);
280264
```
281265
282-
!!! warning "Lifetime risk"
283-
This operation is **lazy**: its result is an expression template, which refers to its operands
284-
instead of owning its own copy of the data. The result is valid only as long as its operands
285-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
286-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
266+
--8<-- "lifetime-risk-lazy.md"
287267
288268
## Views and accessors
289269
@@ -298,11 +278,7 @@ template <typename U, typename R>
298278
auto transpose(const Quantity<U, R> &q);
299279
```
300280

301-
!!! warning "Lifetime risk"
302-
This operation is **lazy**: its result is an expression template, which refers to its operands
303-
instead of owning its own copy of the data. The result is valid only as long as its operands
304-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
305-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
281+
--8<-- "lifetime-risk-lazy.md"
306282

307283
### `diagonal`
308284

@@ -317,11 +293,7 @@ template <typename U, typename R>
317293
auto diagonal(const Quantity<U, R> &q, std::ptrdiff_t index);
318294
```
319295
320-
!!! warning "Lifetime risk"
321-
This operation is **lazy**: its result is an expression template, which refers to its operands
322-
instead of owning its own copy of the data. The result is valid only as long as its operands
323-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
324-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
296+
--8<-- "lifetime-risk-lazy.md"
325297
326298
### `row`, `col`
327299
@@ -335,11 +307,7 @@ template <typename U, typename R>
335307
auto col(const Quantity<U, R> &q, std::ptrdiff_t j);
336308
```
337309

338-
!!! warning "Lifetime risk"
339-
This operation is **lazy**: its result is an expression template, which refers to its operands
340-
instead of owning its own copy of the data. The result is valid only as long as its operands
341-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
342-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
310+
--8<-- "lifetime-risk-lazy.md"
343311

344312
### `reverse`
345313

@@ -350,11 +318,7 @@ template <typename U, typename R>
350318
auto reverse(const Quantity<U, R> &q);
351319
```
352320
353-
!!! warning "Lifetime risk"
354-
This operation is **lazy**: its result is an expression template, which refers to its operands
355-
instead of owning its own copy of the data. The result is valid only as long as its operands
356-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
357-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
321+
--8<-- "lifetime-risk-lazy.md"
358322
359323
### `conjugate`
360324
@@ -365,11 +329,7 @@ template <typename U, typename R>
365329
auto conjugate(const Quantity<U, R> &q);
366330
```
367331

368-
!!! warning "Lifetime risk"
369-
This operation is **lazy**: its result is an expression template, which refers to its operands
370-
instead of owning its own copy of the data. The result is valid only as long as its operands
371-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
372-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
332+
--8<-- "lifetime-risk-lazy.md"
373333

374334
### `head`, `tail`, `segment`
375335

@@ -397,11 +357,7 @@ template <typename U, typename R>
397357
auto segment(const Quantity<U, R> &q, std::ptrdiff_t start, std::ptrdiff_t n);
398358
```
399359
400-
!!! warning "Lifetime risk"
401-
This operation is **lazy**: its result is an expression template, which refers to its operands
402-
instead of owning its own copy of the data. The result is valid only as long as its operands
403-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
404-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
360+
--8<-- "lifetime-risk-lazy.md"
405361
406362
### `block`
407363
@@ -421,11 +377,7 @@ auto block(const Quantity<U, R> &q,
421377
std::ptrdiff_t cols);
422378
```
423379

424-
!!! warning "Lifetime risk"
425-
This operation is **lazy**: its result is an expression template, which refers to its operands
426-
instead of owning its own copy of the data. The result is valid only as long as its operands
427-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
428-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
380+
--8<-- "lifetime-risk-lazy.md"
429381

430382
### `replicate`
431383

@@ -441,11 +393,7 @@ template <typename U, typename R>
441393
auto replicate(const Quantity<U, R> &q, std::ptrdiff_t row_factor, std::ptrdiff_t col_factor);
442394
```
443395
444-
!!! warning "Lifetime risk"
445-
This operation is **lazy**: its result is an expression template, which refers to its operands
446-
instead of owning its own copy of the data. The result is valid only as long as its operands
447-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
448-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
396+
--8<-- "lifetime-risk-lazy.md"
449397
450398
## Matrix operations
451399
@@ -459,8 +407,4 @@ template <typename U, typename R>
459407
auto inverse(const Quantity<U, R> &q);
460408
```
461409

462-
!!! warning "Lifetime risk"
463-
This operation is **lazy**: its result is an expression template, which refers to its operands
464-
instead of owning its own copy of the data. The result is valid only as long as its operands
465-
are alive. If it needs to outlive them, materialize it with [`eval()`](#eval). See our
466-
[Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
410+
--8<-- "lifetime-risk-lazy.md"

docs/reference/quantity.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,7 @@ the [unit slots](../discussion/idioms/unit-slots.md) discussion for valid choice
347347
produced by the conversion operation. (This is usually the same as the input `Rep`, but can differ
348348
in rare cases, such as integer promotion, or Eigen expression templates.)
349349

350-
!!! warning "Lifetime risk"
351-
If the result of this operation is an Eigen expression template, it refers to its operands
352-
instead of owning its own copy of the data. The result is valid only as long as its operands
353-
are alive. If it needs to outlive them, materialize it with [`eval()`](./eigen.md#eval). See
354-
our [Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
350+
--8<-- "lifetime-risk-maybe-lazy.md"
355351

356352
**With** a template argument, `.as<T>(unit)`, the output `Rep` will be `T`.
357353

@@ -379,11 +375,7 @@ slots](../discussion/idioms/unit-slots.md) discussion for valid choices for `uni
379375
produced by the conversion operation. (This is usually the same as the input `Rep`, but can differ
380376
in rare cases, such as integer promotion, or Eigen expression templates.)
381377

382-
!!! warning "Lifetime risk"
383-
If the result of this operation is an Eigen expression template, it refers to its operands
384-
instead of owning its own copy of the data. The result is valid only as long as its operands
385-
are alive. If it needs to outlive them, materialize it with [`eval()`](./eigen.md#eval). See
386-
our [Eigen safety guide](../discussion/concepts/eigen_safety.md) to learn more.
378+
--8<-- "lifetime-risk-maybe-lazy.md"
387379

388380

389381
**With** a template argument, `.in<T>(unit)`, the output type will be `T`.

mkdocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ markdown_extensions:
5858
- pymdownx.inlinehilite
5959
- pymdownx.keys
6060
- pymdownx.smartsymbols
61+
# Reusable text snippets, included via `--8<-- "file.md"`. These live outside of `docs/` because
62+
# they are not pages in their own right: they get inlined into the pages that include them.
63+
- pymdownx.snippets:
64+
base_path: [doc_snippets]
65+
check_paths: true
6166
- pymdownx.superfences:
6267
custom_fences:
6368
- name: mermaid

0 commit comments

Comments
 (0)