vdoc: native syntax highlighting, system font, and intergrate normalize.css
parent
c2fe4ffa85
commit
c1ccd56119
|
@ -1,3 +1,147 @@
|
||||||
|
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
||||||
|
html {
|
||||||
|
line-height: 1.15;
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2em;
|
||||||
|
margin: 0.67em 0;
|
||||||
|
}
|
||||||
|
hr {
|
||||||
|
box-sizing: content-box;
|
||||||
|
height: 0;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
font-family: monospace, monospace;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
abbr[title] {
|
||||||
|
border-bottom: none;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-decoration: underline dotted;
|
||||||
|
}
|
||||||
|
b,
|
||||||
|
strong {
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
code,
|
||||||
|
kbd,
|
||||||
|
samp {
|
||||||
|
font-family: monospace, monospace;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
small {
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
sub,
|
||||||
|
sup {
|
||||||
|
font-size: 75%;
|
||||||
|
line-height: 0;
|
||||||
|
position: relative;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
sub {
|
||||||
|
bottom: -0.25em;
|
||||||
|
}
|
||||||
|
sup {
|
||||||
|
top: -0.5em;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
optgroup,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 100%;
|
||||||
|
line-height: 1.15;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
button,
|
||||||
|
input {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
button,
|
||||||
|
select {
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
button,
|
||||||
|
[type="button"],
|
||||||
|
[type="reset"],
|
||||||
|
[type="submit"] {
|
||||||
|
-webkit-appearance: button;
|
||||||
|
}
|
||||||
|
button::-moz-focus-inner,
|
||||||
|
[type="button"]::-moz-focus-inner,
|
||||||
|
[type="reset"]::-moz-focus-inner,
|
||||||
|
[type="submit"]::-moz-focus-inner {
|
||||||
|
border-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
button:-moz-focusring,
|
||||||
|
[type="button"]:-moz-focusring,
|
||||||
|
[type="reset"]:-moz-focusring,
|
||||||
|
[type="submit"]:-moz-focusring {
|
||||||
|
outline: 1px dotted ButtonText;
|
||||||
|
}
|
||||||
|
fieldset {
|
||||||
|
padding: 0.35em 0.75em 0.625em;
|
||||||
|
}
|
||||||
|
legend {
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: inherit;
|
||||||
|
display: table;
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
progress {
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
[type="checkbox"],
|
||||||
|
[type="radio"] {
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
[type="number"]::-webkit-inner-spin-button,
|
||||||
|
[type="number"]::-webkit-outer-spin-button {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
[type="search"] {
|
||||||
|
-webkit-appearance: textfield;
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
[type="search"]::-webkit-search-decoration {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
::-webkit-file-upload-button {
|
||||||
|
-webkit-appearance: button;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
summary {
|
||||||
|
display: list-item;
|
||||||
|
}
|
||||||
|
template {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
:root {
|
:root {
|
||||||
--background-color: #fff;
|
--background-color: #fff;
|
||||||
--timestamp-color: #b8c2cc;
|
--timestamp-color: #b8c2cc;
|
||||||
|
@ -19,15 +163,17 @@
|
||||||
--toc-font-color: #2779bd;
|
--toc-font-color: #2779bd;
|
||||||
--toc-indent-line-color: #dae1e7;
|
--toc-indent-line-color: #dae1e7;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root.dark .dark-icon {
|
:root.dark .dark-icon {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root:not(.dark) .light-icon {
|
:root:not(.dark) .light-icon {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
color: #000;
|
color: #000;
|
||||||
|
@ -55,8 +201,11 @@ body {
|
||||||
--toc-indent-line-color: #1a202c;
|
--toc-indent-line-color: #1a202c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Reset for menus */
|
/** Reset for menus */
|
||||||
.doc-nav ul, .doc-toc ul {
|
|
||||||
|
.doc-nav ul,
|
||||||
|
.doc-toc ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -81,40 +230,50 @@ body {
|
||||||
scrollbar-color: #a0aec0 transparent;
|
scrollbar-color: #a0aec0 transparent;
|
||||||
scrollbar-color: var(--menu-scrollbar-color) transparent;
|
scrollbar-color: var(--menu-scrollbar-color) transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
*::-webkit-scrollbar {
|
*::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
*::-webkit-scrollbar-track {
|
*::-webkit-scrollbar-track {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
*::-webkit-scrollbar-thumb {
|
*::-webkit-scrollbar-thumb {
|
||||||
background-color: #a0aec0;
|
background-color: #a0aec0;
|
||||||
background-color: var(--menu-scrollbar-color);
|
background-color: var(--menu-scrollbar-color);
|
||||||
border: 3px solid transparent;
|
border: 3px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-nav li {
|
.doc-nav li {
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-nav .content.show {
|
.doc-nav .content.show {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-nav .content.hidden {
|
.doc-nav .content.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-nav #toggle-menu {
|
.doc-nav #toggle-menu {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 0.3rem;
|
padding: 0.3rem;
|
||||||
fill: #fff;
|
fill: #fff;
|
||||||
fill: var(--menu-toggle-icon-color);
|
fill: var(--menu-toggle-icon-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-nav #toggle-menu:active {
|
.doc-nav #toggle-menu:active {
|
||||||
background-color: #00000044;
|
background-color: #00000044;
|
||||||
background-color: var(--menu-toggle-icon-hover-color);
|
background-color: var(--menu-toggle-icon-hover-color);
|
||||||
border-radius: 5rem;
|
border-radius: 5rem;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container {
|
|
||||||
position: relative; /* IE11 */
|
.doc-nav>.heading-container {
|
||||||
|
position: relative;
|
||||||
|
/* IE11 */
|
||||||
position: sticky;
|
position: sticky;
|
||||||
position: -webkit-sticky;
|
position: -webkit-sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -122,31 +281,37 @@ body {
|
||||||
background-color: var(--menu-background-color);
|
background-color: var(--menu-background-color);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading {
|
|
||||||
|
.doc-nav>.heading-container>.heading {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0 2rem;
|
padding: 0 2rem;
|
||||||
height: 56px;
|
height: 56px;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .module {
|
|
||||||
|
.doc-nav>.heading-container>.heading>.module {
|
||||||
font-size: 1.6rem;
|
font-size: 1.6rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .toggle-version-container {
|
|
||||||
|
.doc-nav>.heading-container>.heading>.toggle-version-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .toggle-version-container > #dark-mode-toggle {
|
|
||||||
|
.doc-nav>.heading-container>.heading>.toggle-version-container>#dark-mode-toggle {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
fill: #fff;
|
fill: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .toggle-version-container > #dark-mode-toggle > svg {
|
|
||||||
|
.doc-nav>.heading-container>.heading>.toggle-version-container>#dark-mode-toggle>svg {
|
||||||
width: 1.2rem;
|
width: 1.2rem;
|
||||||
height: 1.2rem;
|
height: 1.2rem;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > #search {
|
|
||||||
|
.doc-nav>.heading-container>.heading>#search {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0.2rem;
|
border-radius: 0.2rem;
|
||||||
|
@ -159,37 +324,45 @@ body {
|
||||||
margin-left: -0.6rem;
|
margin-left: -0.6rem;
|
||||||
margin-right: -0.6rem;
|
margin-right: -0.6rem;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > #search::placeholder {
|
|
||||||
|
.doc-nav>.heading-container>.heading>#search::placeholder {
|
||||||
color: #edf2f7;
|
color: #edf2f7;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > #search:-ms-input-placeholder {
|
|
||||||
|
.doc-nav>.heading-container>.heading>#search:-ms-input-placeholder {
|
||||||
color: #edf2f7;
|
color: #edf2f7;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.doc-nav > .content {
|
|
||||||
|
.doc-nav>.content {
|
||||||
padding: 0 2rem 2rem 2rem;
|
padding: 0 2rem 2rem 2rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li.active {
|
|
||||||
|
.doc-nav>.content>ul>li.active {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li.open ul {
|
|
||||||
|
.doc-nav>.content>ul>li.open ul {
|
||||||
display: initial;
|
display: initial;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li.open > .menu-row > .dropdown-arrow {
|
|
||||||
|
.doc-nav>.content>ul>li.open>.menu-row>.dropdown-arrow {
|
||||||
transform: initial;
|
transform: initial;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li > .menu-row {
|
|
||||||
|
.doc-nav>.content>ul>li>.menu-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li > .menu-row > .dropdown-arrow {
|
|
||||||
|
.doc-nav>.content>ul>li>.menu-row>.dropdown-arrow {
|
||||||
transform: rotate(-90deg);
|
transform: rotate(-90deg);
|
||||||
height: 18px;
|
height: 18px;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
|
@ -199,28 +372,33 @@ body {
|
||||||
fill: #fff;
|
fill: #fff;
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li > ul {
|
|
||||||
|
.doc-nav>.content>ul>li>ul {
|
||||||
margin: 0.4rem 0;
|
margin: 0.4rem 0;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li > ul > li {
|
|
||||||
|
.doc-nav>.content>ul>li>ul>li {
|
||||||
border-color: #ffffff66;
|
border-color: #ffffff66;
|
||||||
border-color: var(--menu-indent-line-color);
|
border-color: var(--menu-indent-line-color);
|
||||||
border-left-width: 1.7px;
|
border-left-width: 1.7px;
|
||||||
border-left-style: solid;
|
border-left-style: solid;
|
||||||
padding-left: 0.7rem;
|
padding-left: 0.7rem;
|
||||||
}
|
}
|
||||||
.doc-nav > .content > ul > li > ul > li.active {
|
|
||||||
|
.doc-nav>.content>ul>li>ul>li.active {
|
||||||
border-color: #00000066;
|
border-color: #00000066;
|
||||||
border-color: var(--menu-indent-line-active-color);
|
border-color: var(--menu-indent-line-active-color);
|
||||||
}
|
}
|
||||||
.doc-nav > .content a {
|
|
||||||
|
.doc-nav>.content a {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
color: var(--menu-font-color);
|
color: var(--menu-font-color);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
.doc-nav > .content a:hover {
|
|
||||||
|
.doc-nav>.content a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,71 +412,83 @@ body {
|
||||||
padding: 1rem 2rem;
|
padding: 1rem 2rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-content a {
|
.doc-content a {
|
||||||
color: var(--link-color);
|
color: var(--link-color);
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node:not(:last-child) {
|
|
||||||
|
.doc-content>.doc-node:not(:last-child) {
|
||||||
padding: 1rem 0 3rem 0;
|
padding: 1rem 0 3rem 0;
|
||||||
}
|
}
|
||||||
.doc-content > .timestamp {
|
|
||||||
|
.doc-content>.timestamp {
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
color: #b8c2cc;
|
color: #b8c2cc;
|
||||||
color: var(--timestamp-color);
|
color: var(--timestamp-color);
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > .title {
|
|
||||||
|
.doc-content>.doc-node>.title {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
border-bottom: 1px solid #f1f5f8;
|
border-bottom: 1px solid #f1f5f8;
|
||||||
border-bottom: 1px solid var(--title-bottom-line-color);
|
border-bottom: 1px solid var(--title-bottom-line-color);
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > .title > .link {
|
|
||||||
|
.doc-content>.doc-node>.title>.link {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
fill: #dae1e7;
|
fill: #dae1e7;
|
||||||
fill: var(--ref-symbol-color);
|
fill: var(--ref-symbol-color);
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > .title > .link:hover {
|
|
||||||
|
.doc-content>.doc-node>.title>.link:hover {
|
||||||
fill: var(--ref-symbol-hover-color);
|
fill: var(--ref-symbol-hover-color);
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node h1 {
|
|
||||||
|
.doc-content>.doc-node h1 {
|
||||||
font-size: 2.5rem;
|
font-size: 2.5rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node .signature {
|
|
||||||
|
.doc-content>.doc-node .signature {
|
||||||
border-color: #a0aec0;
|
border-color: #a0aec0;
|
||||||
border-color: var(--code-signature-border-color);
|
border-color: var(--code-signature-border-color);
|
||||||
border-left-width: 3px;
|
border-left-width: 3px;
|
||||||
border-left-style: solid;
|
border-left-style: solid;
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > ul > li .task-list-item-checkbox {
|
|
||||||
|
.doc-content>.doc-node>ul>li .task-list-item-checkbox {
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > .title h1,
|
|
||||||
.doc-content > .doc-node > .title h2,
|
.doc-content>.doc-node>.title h1,
|
||||||
.doc-content > .doc-node > .title h3,
|
.doc-content>.doc-node>.title h2,
|
||||||
.doc-content > .doc-node > .title h4,
|
.doc-content>.doc-node>.title h3,
|
||||||
.doc-content > .doc-node > .title h5,
|
.doc-content>.doc-node>.title h4,
|
||||||
.doc-content > .doc-node > .title h6 {
|
.doc-content>.doc-node>.title h5,
|
||||||
|
.doc-content>.doc-node>.title h6 {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
padding-bottom: 0.8rem;
|
padding-bottom: 0.8rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > .title h1 a,
|
|
||||||
.doc-content > .doc-node > .title h2 a,
|
.doc-content>.doc-node>.title h1 a,
|
||||||
.doc-content > .doc-node > .title h3 a,
|
.doc-content>.doc-node>.title h2 a,
|
||||||
.doc-content > .doc-node > .title h4 a,
|
.doc-content>.doc-node>.title h3 a,
|
||||||
.doc-content > .doc-node > .title h5 a,
|
.doc-content>.doc-node>.title h4 a,
|
||||||
.doc-content > .doc-node > .title h6 a {
|
.doc-content>.doc-node>.title h5 a,
|
||||||
|
.doc-content>.doc-node>.title h6 a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #dae1e7;
|
color: #dae1e7;
|
||||||
color: var(--ref-symbol-color);
|
color: var(--ref-symbol-color);
|
||||||
}
|
}
|
||||||
.doc-content > .doc-node > .title h1 a:hover,
|
|
||||||
.doc-content > .doc-node > .title h2 a:hover,
|
.doc-content>.doc-node>.title h1 a:hover,
|
||||||
.doc-content > .doc-node > .title h3 a:hover,
|
.doc-content>.doc-node>.title h2 a:hover,
|
||||||
.doc-content > .doc-node > .title h4 a:hover,
|
.doc-content>.doc-node>.title h3 a:hover,
|
||||||
.doc-content > .doc-node > .title h5 a:hover,
|
.doc-content>.doc-node>.title h4 a:hover,
|
||||||
.doc-content > .doc-node > .title h6 a:hover {
|
.doc-content>.doc-node>.title h5 a:hover,
|
||||||
|
.doc-content>.doc-node>.title h6 a:hover {
|
||||||
color: var(--ref-symbol-hover-color);
|
color: var(--ref-symbol-hover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,12 +503,15 @@ body {
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc::-webkit-scrollbar {
|
.doc-toc::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc li {
|
.doc-toc li {
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc a {
|
.doc-toc a {
|
||||||
color: #2779bd;
|
color: #2779bd;
|
||||||
color: var(--toc-font-color);
|
color: var(--toc-font-color);
|
||||||
|
@ -329,11 +522,13 @@ body {
|
||||||
display: block;
|
display: block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc a:hover {
|
.doc-toc a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc li ul {
|
.doc-toc li ul {
|
||||||
border-color :#dae1e7;
|
border-color: #dae1e7;
|
||||||
border-color: var(--toc-indent-line-color);
|
border-color: var(--toc-indent-line-color);
|
||||||
border-left-width: 2px;
|
border-left-width: 2px;
|
||||||
border-left-style: solid;
|
border-left-style: solid;
|
||||||
|
@ -342,23 +537,25 @@ body {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc li ul a {
|
.doc-toc li ul a {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Medium screen and up */
|
/* Medium screen and up */
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.doc-container {
|
.doc-container {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-content {
|
.doc-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc {
|
.doc-toc {
|
||||||
padding: 1rem 1rem 0 1rem;
|
padding: 1rem 1rem 0 1rem;
|
||||||
position: relative; /* IE11 */
|
position: relative;
|
||||||
|
/* IE11 */
|
||||||
position: sticky;
|
position: sticky;
|
||||||
position: -webkit-sticky;
|
position: -webkit-sticky;
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
|
@ -369,7 +566,7 @@ body {
|
||||||
width: auto;
|
width: auto;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
}
|
}
|
||||||
.doc-toc > ul {
|
.doc-toc>ul {
|
||||||
padding-bottom: 1rem;
|
padding-bottom: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,15 +575,15 @@ body {
|
||||||
.doc-nav.hidden {
|
.doc-nav.hidden {
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading {
|
.doc-nav>.heading-container>.heading {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .toggle-version-container {
|
.doc-nav>.heading-container>.heading>.toggle-version-container {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > #search {
|
.doc-nav>.heading-container>.heading>#search {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,32 +595,30 @@ body {
|
||||||
.doc-nav #toggle-menu {
|
.doc-nav #toggle-menu {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading {
|
.doc-nav>.heading-container>.heading {
|
||||||
height: auto;
|
height: auto;
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
padding-bottom: 1rem;
|
padding-bottom: 1rem;
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .toggle-version-container {
|
.doc-nav>.heading-container>.heading>.toggle-version-container {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 0.2rem;
|
margin-bottom: 0.2rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row-reverse;
|
flex-direction: row-reverse;
|
||||||
}
|
}
|
||||||
.doc-nav > .heading-container > .heading > .toggle-version-container > #dark-mode-toggle {
|
.doc-nav>.heading-container>.heading>.toggle-version-container>#dark-mode-toggle {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
.doc-nav .content.show,
|
.doc-nav .content.show,
|
||||||
.doc-nav .content.hidden {
|
.doc-nav .content.hidden {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-container {
|
.doc-container {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-left: 300px;
|
margin-left: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-toc {
|
.doc-toc {
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
134
cmd/tools/vdoc.v
134
cmd/tools/vdoc.v
|
@ -7,8 +7,43 @@ import os
|
||||||
import os.cmdline
|
import os.cmdline
|
||||||
import strings
|
import strings
|
||||||
import v.doc
|
import v.doc
|
||||||
|
import v.scanner
|
||||||
|
import v.table
|
||||||
|
import v.token
|
||||||
import v.vmod
|
import v.vmod
|
||||||
|
|
||||||
|
enum HighlightTokenTyp {
|
||||||
|
unone
|
||||||
|
atrule
|
||||||
|
attr_name
|
||||||
|
bold
|
||||||
|
boolean
|
||||||
|
builtin
|
||||||
|
char
|
||||||
|
comment
|
||||||
|
constant
|
||||||
|
cdata
|
||||||
|
deleted
|
||||||
|
doctype
|
||||||
|
entity
|
||||||
|
function
|
||||||
|
important
|
||||||
|
inserted
|
||||||
|
italic
|
||||||
|
keyword
|
||||||
|
name
|
||||||
|
number
|
||||||
|
operator
|
||||||
|
prolog
|
||||||
|
property
|
||||||
|
punctuation
|
||||||
|
selector
|
||||||
|
string
|
||||||
|
symbol
|
||||||
|
tag
|
||||||
|
url
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
allowed_formats = ['md', 'markdown', 'json', 'text', 'stdout', 'html', 'htm']
|
allowed_formats = ['md', 'markdown', 'json', 'text', 'stdout', 'html', 'htm']
|
||||||
exe_path = os.executable()
|
exe_path = os.executable()
|
||||||
|
@ -131,15 +166,76 @@ fn (cfg DocConfig) gen_json(idx int) string {
|
||||||
return jw.str()
|
return jw.str()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (cfg DocConfig) gen_html(idx int) string {
|
fn html_highlight(code string, tb &table.Table) string {
|
||||||
dcs := cfg.docs[idx]
|
builtin := ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'byte', 'u16', 'u32', 'u64', 'u128', 'rune', 'f32', 'f64', 'any_int', 'any_float', 'byteptr', 'voidptr', 'any']
|
||||||
mut hw := strings.new_builder(200)
|
highlight_code := fn (tok token.Token, typ HighlightTokenTyp) string {
|
||||||
mut toc := strings.new_builder(200)
|
lit := if typ in [.unone, .operator] { tok.kind.str() } else { tok.lit }
|
||||||
mut doc_node_html := fn (dd doc.DocNode, link string, head bool) string {
|
return if typ in [.unone, .name] { lit } else { '<span class="token $typ">$lit</span>' }
|
||||||
|
}
|
||||||
|
s := scanner.new_scanner(code, .parse_comments)
|
||||||
|
mut tok := s.scan()
|
||||||
|
mut next_tok := s.scan()
|
||||||
|
mut buf := strings.new_builder(200)
|
||||||
|
mut i := 0
|
||||||
|
for i < code.len {
|
||||||
|
if i == tok.pos {
|
||||||
|
mut tok_typ := HighlightTokenTyp.unone
|
||||||
|
match tok.kind {
|
||||||
|
.name {
|
||||||
|
if tok.lit in builtin {
|
||||||
|
tok_typ = .builtin
|
||||||
|
} else if next_tok.kind in [.lcbr, .lpar] {
|
||||||
|
tok_typ = .symbol
|
||||||
|
} else {
|
||||||
|
tok_typ = .name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.comment {
|
||||||
|
tok_typ = .comment
|
||||||
|
}
|
||||||
|
.chartoken {
|
||||||
|
tok_typ = .char
|
||||||
|
}
|
||||||
|
.string {
|
||||||
|
tok_typ = .string
|
||||||
|
}
|
||||||
|
.number {
|
||||||
|
tok_typ = .number
|
||||||
|
}
|
||||||
|
.key_true,
|
||||||
|
.key_false {
|
||||||
|
tok_typ = .boolean
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
|
||||||
|
tok_typ = .keyword
|
||||||
|
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary() || tok.kind.is_relational() || tok.kind.is_infix() {
|
||||||
|
tok_typ = .operator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.write(highlight_code(tok, tok_typ))
|
||||||
|
if next_tok.kind != .eof {
|
||||||
|
i = tok.pos + tok.len
|
||||||
|
tok = next_tok
|
||||||
|
next_tok = s.scan()
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buf.write_b(code[i])
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf.str()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn doc_node_html(dd doc.DocNode, link string, head bool, tb &table.Table) string {
|
||||||
mut dnw := strings.new_builder(200)
|
mut dnw := strings.new_builder(200)
|
||||||
link_svg := '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'
|
link_svg := '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'
|
||||||
head_tag := if head { 'h1' } else { 'h2' }
|
head_tag := if head { 'h1' } else { 'h2' }
|
||||||
md_content := markdown.to_html(dd.comment)
|
md_content := markdown.to_html(dd.comment)
|
||||||
|
hlighted_code := html_highlight(dd.content, tb)
|
||||||
dnw.writeln('<section id="${slug(dd.name)}" class="doc-node">')
|
dnw.writeln('<section id="${slug(dd.name)}" class="doc-node">')
|
||||||
if dd.name != 'README' {
|
if dd.name != 'README' {
|
||||||
dnw.write('<div class="title"><$head_tag>${dd.name} <a href="#${slug(dd.name)}">#</a></$head_tag>')
|
dnw.write('<div class="title"><$head_tag>${dd.name} <a href="#${slug(dd.name)}">#</a></$head_tag>')
|
||||||
|
@ -151,12 +247,17 @@ fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
if head {
|
if head {
|
||||||
dnw.write(md_content)
|
dnw.write(md_content)
|
||||||
} else {
|
} else {
|
||||||
dnw.writeln('<pre class="signature"><code class="language-v">${dd.content}</code></pre>')
|
dnw.writeln('<pre class="signature language-v"><code class="language-v">$hlighted_code</code></pre>')
|
||||||
dnw.writeln(md_content)
|
dnw.writeln(md_content)
|
||||||
}
|
}
|
||||||
dnw.writeln('</section>')
|
dnw.writeln('</section>')
|
||||||
return dnw.str()
|
return dnw.str()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
|
dcs := cfg.docs[idx]
|
||||||
|
mut hw := strings.new_builder(200)
|
||||||
|
mut toc := strings.new_builder(200)
|
||||||
// generate toc first
|
// generate toc first
|
||||||
for cn in dcs.contents {
|
for cn in dcs.contents {
|
||||||
if cn.parent_type !in ['void', ''] { continue }
|
if cn.parent_type !in ['void', ''] { continue }
|
||||||
|
@ -179,7 +280,6 @@ fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
dark_icon := cfg.get_resource('dark.svg', true)
|
dark_icon := cfg.get_resource('dark.svg', true)
|
||||||
menu_icon := cfg.get_resource('menu.svg', true)
|
menu_icon := cfg.get_resource('menu.svg', true)
|
||||||
arrow_icon := cfg.get_resource('arrow.svg', true)
|
arrow_icon := cfg.get_resource('arrow.svg', true)
|
||||||
v_prism_js := cfg.get_resource('v-prism.js', false)
|
|
||||||
v_prism_css := cfg.get_resource('v-prism.css', true)
|
v_prism_css := cfg.get_resource('v-prism.css', true)
|
||||||
|
|
||||||
hw.write('
|
hw.write('
|
||||||
|
@ -189,14 +289,12 @@ fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="x-ua-compatible" content="IE=edge" />
|
<meta http-equiv="x-ua-compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>${dcs.head.name} | vdoc</title>
|
<title>${dcs.head.name} | vdoc</title>')
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Source+Code+Pro:wght@500&display=swap" rel="stylesheet" />
|
|
||||||
<link rel="stylesheet" href="https://necolas.github.io/normalize.css/8.0.1/normalize.css" />')
|
|
||||||
|
|
||||||
// write css
|
// write css
|
||||||
if cfg.inline_assets {
|
if cfg.inline_assets {
|
||||||
hw.write('<style>$v_prism_css</style>')
|
hw.write('\n <style>$v_prism_css</style>')
|
||||||
hw.write('<style>$doc_css_min</style>')
|
hw.write('\n <style>$doc_css_min</style>')
|
||||||
} else {
|
} else {
|
||||||
hw.write('\n <link rel="stylesheet" href="$v_prism_css" />')
|
hw.write('\n <link rel="stylesheet" href="$v_prism_css" />')
|
||||||
hw.write('\n <link rel="stylesheet" href="$doc_css_min" />')
|
hw.write('\n <link rel="stylesheet" href="$doc_css_min" />')
|
||||||
|
@ -266,19 +364,19 @@ fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
}
|
}
|
||||||
hw.write('</ul>\n</nav>\n</header>')
|
hw.write('</ul>\n</nav>\n</header>')
|
||||||
hw.write('<div class="doc-container">\n<div class="doc-content">\n')
|
hw.write('<div class="doc-container">\n<div class="doc-content">\n')
|
||||||
hw.write(doc_node_html(dcs.head, '', true))
|
hw.write(doc_node_html(dcs.head, '', true, dcs.table))
|
||||||
for cn in dcs.contents {
|
for cn in dcs.contents {
|
||||||
if cn.parent_type !in ['void', ''] { continue }
|
if cn.parent_type !in ['void', ''] { continue }
|
||||||
base_dir := os.base_dir(os.real_path(cfg.input_path))
|
base_dir := os.base_dir(os.real_path(cfg.input_path))
|
||||||
file_path_name := cn.file_path.replace('$base_dir/', '')
|
file_path_name := cn.file_path.replace('$base_dir/', '')
|
||||||
hw.write(doc_node_html(cn, get_src_link(cfg.manifest.repo_url, file_path_name, cn.pos.line), false))
|
hw.write(doc_node_html(cn, get_src_link(cfg.manifest.repo_url, file_path_name, cn.pos.line), false, dcs.table))
|
||||||
|
|
||||||
children := dcs.contents.find_children_of(cn.name)
|
children := dcs.contents.find_children_of(cn.name)
|
||||||
|
|
||||||
if children.len != 0 {
|
if children.len != 0 {
|
||||||
for child in children {
|
for child in children {
|
||||||
child_file_path_name := child.file_path.replace('$base_dir/', '')
|
child_file_path_name := child.file_path.replace('$base_dir/', '')
|
||||||
hw.write(doc_node_html(child, get_src_link(cfg.manifest.repo_url, child_file_path_name, child.pos.line), false))
|
hw.write(doc_node_html(child, get_src_link(cfg.manifest.repo_url, child_file_path_name, child.pos.line), false, dcs.table))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,14 +385,10 @@ fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
hw.write('<div class="doc-toc">\n\n<ul>\n${toc.str()}</ul>\n</div>')
|
hw.write('<div class="doc-toc">\n\n<ul>\n${toc.str()}</ul>\n</div>')
|
||||||
}
|
}
|
||||||
hw.write('</div></div>')
|
hw.write('</div></div>')
|
||||||
hw.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-core.min.js"></script>
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-clike.min.js"></script>')
|
|
||||||
if cfg.inline_assets {
|
if cfg.inline_assets {
|
||||||
hw.write('<script>$doc_js_min</script>')
|
hw.write('<script>$doc_js_min</script>')
|
||||||
hw.write('<script>$v_prism_js</script>')
|
|
||||||
} else {
|
} else {
|
||||||
hw.write('<script src="$doc_js_min"></script>')
|
hw.write('<script src="$doc_js_min"></script>')
|
||||||
hw.write('<script src="$v_prism_js"></script>')
|
|
||||||
}
|
}
|
||||||
hw.write('</body>
|
hw.write('</body>
|
||||||
</html>')
|
</html>')
|
||||||
|
|
Loading…
Reference in New Issue