Skip to content

Commit

Permalink
Tweak API documentation presentation to match pdoc3's style
Browse files Browse the repository at this point in the history
This is a generally cleaner style, that avoids using link-like colours
for the API text, has sufficient contrast for all of the content, has a
consistent and distinct font-weight and is visually distinct.
  • Loading branch information
pradyunsg committed Nov 15, 2021
1 parent edfbf30 commit 8e5f499
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
59 changes: 31 additions & 28 deletions src/furo/assets/styles/content/_api.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// to select the relevant items.
// API docs!
dl.py, dl.cpp, dl.c, dl.js
dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)
// Tweak the spacing of all the things!
dd
margin-left: 2rem
Expand Down Expand Up @@ -40,29 +40,43 @@ dl.py, dl.cpp, dl.c, dl.js
&:target
background-color: var(--color-api-highlight-on-target)

dl.class,
dl.function,
dl.method,
dl.enum,
dl.enum-class,
dl.enum-struct,
dl.type,
dl.exception
> dt
padding-left: 3em
text-indent: -2.5em
.sig
font-weight: bold

font-size: var(--api-font-size)
font-family: var(--font-stack--monospace)

padding-top: 0.25rem
padding-bottom: 0.25rem
padding-right: 0.5rem

// adjust the size of the [source] link on the right.
a.reference.internal
.viewcode-link
width: 3.5rem
// These are intentionally em, to properly match the font size.
padding-left: 3em
text-indent: -2.5em

border-radius: 0.25rem

background: var(--color-api-background)

&:hover
background: var(--color-api-background-hover)

// adjust the size of the [source] link on the right.
a.reference.internal
.viewcode-link
font-weight: normal
width: 3.5rem

em.property
font-style: normal
&:first-child
color: var(--color-api-keyword)
.py.function,
.py.method
> .sig::before
content: "def "
color: var(--color-api-keyword)
.sig-name
font-weight: bold
color: var(--color-api-name)
.sig-prename
color: var(--color-api-pre-name)
Expand All @@ -82,14 +96,3 @@ div.versionadded, div.versionchanged, div.deprecated
.viewcode-link, .viewcode-back
float: right
text-align: right

.sig
font-size: var(--api-font-size)
font-family: var(--font-stack--monospace)
padding: 0.25rem 0.5rem
border-radius: 0.25rem

background: var(--color-api-background)

&:hover
background: var(--color-api-background-hover)
11 changes: 6 additions & 5 deletions src/furo/assets/styles/variables/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
--color-api-background: var(--color-background-secondary);
--color-api-background-hover: var(--color-background-hover);
--color-api-overall: var(--color-foreground-secondary);
--color-api-name: var(--color-brand-content);
--color-api-pre-name: var(--color-brand-content);
--color-api-paren: var(--color-foreground-primary);
--color-api-keyword: var(--color-problematic);
--color-api-name: var(--color-problematic);
--color-api-pre-name: var(--color-problematic);
--color-api-paren: var(--color-foreground-secondary);
--color-api-keyword: var(--color-foreground-primary);
--color-api-highlight-on-target: #ffffcc;

// Inline code background
Expand Down Expand Up @@ -125,7 +125,7 @@
}

@mixin colors-dark {
--color-problematic: #e25050;
--color-problematic: #ee5151;

// Base Colors
--color-foreground-primary: #ffffffcc; // for main text and headings
Expand Down Expand Up @@ -155,6 +155,7 @@
--color-guilabel-border: #13395f80;

// API documentation
--color-api-keyword: var(--color-foreground-secondary);
--color-api-highlight-on-target: #333300;

// Admonitions
Expand Down

0 comments on commit 8e5f499

Please sign in to comment.