Skip to content

Commit

Permalink
Merge pull request #301152 from DanielSidhion/examples-collapsible
Browse files Browse the repository at this point in the history
nixos-render-docs: make examples collapsible by default
  • Loading branch information
infinisil authored Apr 4, 2024
2 parents bb0849e + 2ce2079 commit 60e0053
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions doc/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,22 @@ div.appendix div.example {
margin-top: 1.5em;
}

div.book div.example details,
div.appendix div.example details {
padding: 5px;
}

div.book div.example details[open],
div.appendix div.example details[open] {
border: 1px solid #aaa;
border-radius: 4px;
}

div.book div.example details>summary,
div.appendix div.example details>summary {
cursor: pointer;
}

div.book br.example-break,
div.appendix br.example-break {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ def ordered_list_close(self, token: Token, tokens: Sequence[Token], i: int) -> s
def example_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
if id := cast(str, token.attrs.get('id', '')):
id = f'id="{escape(id, True)}"' if id else ''
return f'<div class="example"><span {id} ></span>'
return f'<div class="example"><span {id} ></span><details>'
def example_close(self, token: Token, tokens: Sequence[Token], i: int) -> str:
return '</div></div><br class="example-break" />'
return '</div></details></div><br class="example-break" />'
def example_title_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
return '<p class="title"><strong>'
return '<summary><span class="title"><strong>'
def example_title_close(self, token: Token, tokens: Sequence[Token], i: int) -> str:
return '</strong></p><div class="example-contents">'
return '</strong></span></summary><div class="example-contents">'
def image(self, token: Token, tokens: Sequence[Token], i: int) -> str:
src = self._pull_image(cast(str, token.attrs['src']))
alt = f'alt="{escape(token.content, True)}"' if token.content else ""
Expand Down

0 comments on commit 60e0053

Please sign in to comment.