Skip to content

Commit

Permalink
[doc] improve see/hide buttons outside of rustdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhenrymantilla committed Jul 21, 2022
1 parent ad6ed19 commit 7d9ce3d
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "lending-iterator"
authors = [
"Daniel Henry-Mantilla <[email protected]>",
]
version = "0.1.3" # Keep in sync
version = "0.1.4" # Keep in sync
edition = "2021"

license = "Zlib OR MIT OR Apache-2.0"
Expand Down Expand Up @@ -56,7 +56,7 @@ macro-vis.version = "0.1.1"

[dependencies.lending-iterator-proc_macros]
path = "src/proc_macros"
version = "0.1.3" # Keep in sync
version = "0.1.4" # Keep in sync

[dev-dependencies]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Fully generic `LendingIterator`s in stable Rust.

## Examples

<details open class="custom"><summary><span class="summary-box">Click to see/hide</span></summary>
<details open class="custom"><summary><span class="summary-box"><span>Click to hide</span></span></summary>

### `windows_mut()`!

Expand Down Expand Up @@ -134,7 +134,7 @@ As noted in this **6-year-old issue**:

Such an API can easily be provided using the HKT API of this crate:

<details class="custom"><summary><span class="summary-box">Click to see/hide</summary>
<details class="custom"><summary><span class="summary-box"><span>Click to show<span></span></summary>

```rust
use ::lending_iterator::higher_kinded_types::{*, Apply as A};
Expand Down
31 changes: 23 additions & 8 deletions fix-docsrs-li-details-summary.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<style>
@import url('http://fonts.cdnfonts.com/css/apercu');
@import url('http://fonts.cdnfonts.com/css/fira-code-2');

details.custom > summary {
display: list-item;
/* https://medium.com/simple-human/buttons-shouldnt-have-a-hand-cursor-b11e99ca374b */
Expand All @@ -9,21 +12,31 @@
display: inline-block;
}

details.custom > summary span.summary-to-hide,
details[open].custom > summary span.summary-to-see {
display: none;
details.custom > summary > .summary-box > span {
visibility: hidden;
position: relative;
}
details.custom > summary > .summary-box > span:after {
content: "Click to show";
visibility: visible;
position: absolute;
top: 0;
left: 0;
}
details.custom > summary span.summary-to-see,
details[open].custom > summary span.summary-to-hide {
display: inline;
details[open].custom > summary > .summary-box > span:after {
content: "Click to hide";
visibility: visible;
position: absolute;
top: 0;
left: 0;
}

/**
* Button style from https://github.com/ubuwaits/css3-buttons
* MIT-Licensed under the name of Chad Mazzola
* rev: c5d2eccd18c0be21c291982e40da0c590f8bc32f
*
* I changed the following: I removed the padding, the width and `cursor: pointer`.
* I made a few changes, the original is then commented out just above each.
**/
.summary-box {
background-color: #eeeeee;
Expand All @@ -37,8 +50,10 @@
border-bottom: 1px solid #bbb;
border-radius: 3px;
color: #333;
font: bold 11px/1 "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
/* font: bold 11px/1 "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; */
font: bold 11px/1 "Fira Code", "Apercu Mono", "Courier New", sans-serif;
/* padding: 8px 0; */
padding-top: 2px;
text-align: center;
text-shadow: 0 1px 0 #eee;
/* width: 150px; */
Expand Down
14 changes: 7 additions & 7 deletions src/higher_kinded_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

### What are Higher-Kinded Types?

<details class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details class="custom"><summary><span class="summary-box"><span>Click to show</span></span></summary>

A higher-kinded type is an actual / **full / standalone** type which is, itself,
"generic", or rather, to which we can further feed generic parameters (such as
Expand Down Expand Up @@ -99,11 +99,11 @@ HKTs come into play the moment we need "generic generics".

### Why? What are Higher-Kinded Types _for_?

<details class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details class="custom"><summary><span class="summary-box"><span>Click to show</span></span></summary>

- #### Type-HKTs

<details class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details class="custom"><summary><span class="summary-box"><span>Click to show</span></span></summary>

Consider the following pseudo-code:

Expand Down Expand Up @@ -172,7 +172,7 @@ HKTs come into play the moment we need "generic generics".

- #### Lifetime HKTs

<details open class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details open class="custom"><summary><span class="summary-box"><span>Click to hide</span></span></summary>

Another use case can be around lifetimes, when dealing with higher-order
lifetimes (_e.g._, when exposing borrows of callee local variables to a
Expand Down Expand Up @@ -442,7 +442,7 @@ HKTs come into play the moment we need "generic generics".
### How? → Back to real Rust
<details class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details class="custom"><summary><span class="summary-box"><span>Click to show</span></span></summary>
This, in real Rust, comes with three challenges:
Expand Down Expand Up @@ -626,7 +626,7 @@ trait HKT = for<'any> WithLifetime<'any>;
## The three important things to remember when working with these HKT APIs
<details open class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details open class="custom"><summary><span class="summary-box"><span>Click to hide</span></span></summary>
1. **APIs use `T : HKT` to express `T : <'lt>`**
Expand Down Expand Up @@ -735,7 +735,7 @@ trait HKT = for<'any> WithLifetime<'any>;
## Illustration: fully working code for the `debug_each` example
<details class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
<details class="custom"><summary><span class="summary-box"><span>Click to show</span></span></summary>
```rust
#![forbid(unsafe_code)]
Expand Down
2 changes: 1 addition & 1 deletion src/lending_iterator/_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type Item<'lt, I : LendingIterator> =
/// type of the `fn next(&'_ mut self)` method being allowed to depend on that
/// `'_`**.
///
/// <details open class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
/// <details open class="custom"><summary><span class="summary-box"><span>Click to hide</span></span></summary>
///
/// - That type is called the `Item<'_>` type, and is a
/// [`generic_associated_type`](#a-generic-associated-type).
Expand Down
2 changes: 1 addition & 1 deletion src/lending_iterator/adapters/_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! # Example
//!
//! <details open class="custom"><summary><span class="summary-box"><span class="summary-to-see">Click to see</span><span class="summary-to-hide">Click to hide</span></span></summary>
//! <details open class="custom"><summary><span class="summary-box"><span>Click to hide</span></span></summary>
//!
/*! - ```rust
use ::lending_iterator::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/proc_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "lending-iterator-proc_macros"
authors = [
"Daniel Henry-Mantilla <[email protected]>"
]
version = "0.1.3" # Keep in sync
version = "0.1.4" # Keep in sync
edition = "2021"

license = "Zlib OR MIT OR Apache-2.0"
Expand Down

0 comments on commit 7d9ce3d

Please sign in to comment.