mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vdoc: refactor theme files (#19024)
This commit is contained in:
parent
43800a05e8
commit
6b978a6b5a
@ -6,7 +6,7 @@ end_of_line = lf
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[*.v]
|
[*.{v,js,css}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
|
|
||||||
[*.{bat,cmd}]
|
[*.{bat,cmd}]
|
||||||
|
19
.github/workflows/module_docs_lint.yml
vendored
Normal file
19
.github/workflows/module_docs_lint.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Code CI vlib modules
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**/cmd/tools/vdoc/theme/**'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '**/cmd/tools/vdoc/theme/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-module-docs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Check Formatting
|
||||||
|
uses: actionsx/prettier@v2
|
||||||
|
with:
|
||||||
|
args: --check cmd/tools/vdoc/theme
|
@ -10,6 +10,7 @@ import v.ast
|
|||||||
import v.token
|
import v.token
|
||||||
import v.doc
|
import v.doc
|
||||||
import v.pref
|
import v.pref
|
||||||
|
import v.util { tabs }
|
||||||
|
|
||||||
const (
|
const (
|
||||||
css_js_assets = ['doc.css', 'normalize.css', 'doc.js', 'dark-mode.js']
|
css_js_assets = ['doc.css', 'normalize.css', 'doc.js', 'dark-mode.js']
|
||||||
@ -249,27 +250,27 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
|
|||||||
version).replace('{{ light_icon }}', vd.assets['light_icon']).replace('{{ dark_icon }}',
|
version).replace('{{ light_icon }}', vd.assets['light_icon']).replace('{{ dark_icon }}',
|
||||||
vd.assets['dark_icon']).replace('{{ menu_icon }}', vd.assets['menu_icon']).replace('{{ head_assets }}',
|
vd.assets['dark_icon']).replace('{{ menu_icon }}', vd.assets['menu_icon']).replace('{{ head_assets }}',
|
||||||
if cfg.inline_assets {
|
if cfg.inline_assets {
|
||||||
'\n${tabs[0]}<style>' + vd.assets['doc_css'] + '</style>\n${tabs[0]}<style>' +
|
'<style>${vd.assets['doc_css']}</style>
|
||||||
vd.assets['normalize_css'] + '</style>\n${tabs[0]}<script>' +
|
${tabs(2)}<style>${vd.assets['normalize_css']}</style>
|
||||||
vd.assets['dark_mode_js'] + '</script>'
|
${tabs(2)}<script>${vd.assets['dark_mode_js']}</script>'
|
||||||
} else {
|
} else {
|
||||||
'\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['doc_css'] +
|
'<link rel="stylesheet" href="${vd.assets['doc_css']}" />
|
||||||
'" />\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['normalize_css'] +
|
${tabs(2)}<link rel="stylesheet" href="${vd.assets['normalize_css']}" />
|
||||||
'" />\n${tabs[0]}<script src="' + vd.assets['dark_mode_js'] + '"></script>'
|
${tabs(2)}<script src="${vd.assets['dark_mode_js']}"></script>'
|
||||||
}).replace('{{ toc_links }}', if cfg.is_multi || vd.docs.len > 1 {
|
}).replace('{{ toc_links }}', if cfg.is_multi || vd.docs.len > 1 {
|
||||||
modules_toc_str
|
modules_toc_str
|
||||||
} else {
|
} else {
|
||||||
symbols_toc_str
|
symbols_toc_str
|
||||||
}).replace('{{ contents }}', contents.str()).replace('{{ right_content }}', if cfg.is_multi
|
}).replace('{{ contents }}', contents.str()).replace('{{ right_content }}', if cfg.is_multi
|
||||||
&& d.head.name != 'README' {
|
&& d.head.name != 'README' {
|
||||||
'<div class="doc-toc"><ul>' + symbols_toc_str + '</ul></div>'
|
'<div class="doc-toc"><ul>${symbols_toc_str}</ul></div>'
|
||||||
} else {
|
} else {
|
||||||
''
|
''
|
||||||
}).replace('{{ footer_content }}', gen_footer_text(d, !cfg.no_timestamp)).replace('{{ footer_assets }}',
|
}).replace('{{ footer_content }}', gen_footer_text(d, !cfg.no_timestamp)).replace('{{ footer_assets }}',
|
||||||
if cfg.inline_assets {
|
if cfg.inline_assets {
|
||||||
'<script>' + vd.assets['doc_js'] + '</script>'
|
'<script>${vd.assets['doc_js']}</script>'
|
||||||
} else {
|
} else {
|
||||||
'<script src="' + vd.assets['doc_js'] + '"></script>'
|
'<script src="${vd.assets['doc_js']}"></script>'
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -407,12 +408,12 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
|
|||||||
node_id = 'readme_${node_id}'
|
node_id = 'readme_${node_id}'
|
||||||
hash_link = ' <a href="#${node_id}">#</a>'
|
hash_link = ' <a href="#${node_id}">#</a>'
|
||||||
}
|
}
|
||||||
dnw.writeln('${tabs[1]}<section id="${node_id}" class="doc-node${node_class}">')
|
dnw.writeln('${tabs(2)}<section id="${node_id}" class="doc-node${node_class}">')
|
||||||
if dn.name.len > 0 {
|
if dn.name.len > 0 {
|
||||||
if dn.kind == .const_group {
|
if dn.kind == .const_group {
|
||||||
dnw.write_string('${tabs[2]}<div class="title"><${head_tag}>${sym_name}${hash_link}</${head_tag}>')
|
dnw.write_string('${tabs(3)}<div class="title"><${head_tag}>${sym_name}${hash_link}</${head_tag}>')
|
||||||
} else {
|
} else {
|
||||||
dnw.write_string('${tabs[2]}<div class="title"><${head_tag}>${dn.kind} ${sym_name}${hash_link}</${head_tag}>')
|
dnw.write_string('${tabs(3)}<div class="title"><${head_tag}>${dn.kind} ${sym_name}${hash_link}</${head_tag}>')
|
||||||
}
|
}
|
||||||
if link.len != 0 {
|
if link.len != 0 {
|
||||||
dnw.write_string('<a class="link" rel="noreferrer" target="_blank" href="${link}">${link_svg}</a>')
|
dnw.write_string('<a class="link" rel="noreferrer" target="_blank" href="${link}">${link_svg}</a>')
|
||||||
|
5
cmd/tools/vdoc/theme/.prettierrc
Normal file
5
cmd/tools/vdoc/theme/.prettierrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"useTabs": true,
|
||||||
|
"printWidth": 100,
|
||||||
|
"singleQuote": true
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
(function() {
|
(function () {
|
||||||
var html = document.getElementsByTagName('html')[0];
|
if (localStorage.getItem('dark-mode') === 'true') {
|
||||||
if (localStorage.getItem('dark-mode') === 'true') {
|
document.querySelector('html').classList.add('dark');
|
||||||
html.classList.add('dark');
|
}
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,235 +1,204 @@
|
|||||||
(function () {
|
(function () {
|
||||||
if (document.body.scrollIntoView) {
|
const docnav = document.querySelector('.doc-nav');
|
||||||
var docnav = document.querySelector('.doc-nav');
|
const active = docnav.querySelector('li.active');
|
||||||
var active = docnav.querySelector('li.active');
|
active?.scrollIntoView({ block: 'center', inline: 'nearest' });
|
||||||
if (active) {
|
setupMobileToggle();
|
||||||
active.scrollIntoView({ block: 'center', inline: 'nearest' });
|
setupDarkMode();
|
||||||
}
|
setupScrollSpy();
|
||||||
}
|
setupSearch();
|
||||||
setupScrollSpy();
|
setupCollapse();
|
||||||
setupMobileToggle();
|
|
||||||
setupDarkMode();
|
|
||||||
setupSearch();
|
|
||||||
setupCollapse();
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function setupScrollSpy() {
|
function setupScrollSpy() {
|
||||||
var sectionPositions = [];
|
const sections = document.querySelectorAll('section');
|
||||||
var sections = document.querySelectorAll('section');
|
const sectionPositions = Array.from(sections).map((section) => section.offsetTop);
|
||||||
sections.forEach(function (section) {
|
let scrollPos = 0;
|
||||||
sectionPositions.push(section.offsetTop);
|
window.addEventListener('scroll', () => {
|
||||||
});
|
const toc = document.querySelector('.doc-toc');
|
||||||
var scrollPos = 0;
|
// Reset classes
|
||||||
window.addEventListener('scroll', function (_) {
|
toc.querySelectorAll('a[class="active"]').forEach((link) => link.classList.remove('active'));
|
||||||
// Reset classes
|
// Set current menu link as active
|
||||||
document.querySelectorAll('.doc-toc a[class="active"]').forEach(function (link) {
|
let scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
|
||||||
link.classList.remove('active');
|
for (const [i, position] of sectionPositions.entries()) {
|
||||||
});
|
if (position >= scrollPosition) {
|
||||||
// Set current menu link as active
|
const section = sections[i];
|
||||||
var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
|
const link = toc.querySelector('a[href="#' + section.id + '"]');
|
||||||
for (var i = 0; i < sectionPositions.length; i++) {
|
if (link) {
|
||||||
var section = sections[i];
|
link.classList.add('active');
|
||||||
var position = sectionPositions[i];
|
const tocHeight = toc.clientHeight;
|
||||||
if (position >= scrollPosition) {
|
const scrollTop = toc.scrollTop;
|
||||||
var link = document.querySelector('.doc-toc a[href="#' + section.id + '"]');
|
if (
|
||||||
if (link) {
|
document.body.getBoundingClientRect().top < scrollPos &&
|
||||||
link.classList.add('active');
|
scrollTop < link.offsetTop - 10
|
||||||
var docToc = document.querySelector('.doc-toc');
|
) {
|
||||||
var tocHeight = docToc.clientHeight;
|
toc.scrollTop = link.clientHeight + link.offsetTop - tocHeight + 10;
|
||||||
var scrollTop = docToc.scrollTop;
|
} else if (scrollTop > link.offsetTop - 10) {
|
||||||
if ((document.body.getBoundingClientRect()).top < scrollPos && scrollTop < link.offsetTop - 10) {
|
toc.scrollTop = link.offsetTop - 10;
|
||||||
docToc.scrollTop = link.clientHeight + link.offsetTop - tocHeight + 10;
|
}
|
||||||
} else if (scrollTop > link.offsetTop - 10) {
|
}
|
||||||
docToc.scrollTop = link.offsetTop - 10;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
scrollPos = document.body.getBoundingClientRect().top;
|
||||||
}
|
});
|
||||||
}
|
|
||||||
scrollPos = (document.body.getBoundingClientRect()).top;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMobileToggle() {
|
function setupMobileToggle() {
|
||||||
var toggle = document.getElementById('toggle-menu');
|
document.getElementById('toggle-menu').addEventListener('click', () => {
|
||||||
toggle.addEventListener('click', function (_) {
|
const docNav = document.querySelector('.doc-nav');
|
||||||
var docNav = document.querySelector('.doc-nav');
|
const isHidden = docNav.classList.contains('hidden');
|
||||||
var isHidden = docNav.classList.contains('hidden');
|
docNav.classList.toggle('hidden');
|
||||||
docNav.classList.toggle('hidden');
|
const search = docNav.querySelector('.search');
|
||||||
var search = document.querySelector('.doc-nav > .search');
|
// console.log(search);
|
||||||
console.log(search);
|
const searchHasResults = search.classList.contains('has-results');
|
||||||
var searchHasResults = search.classList.contains('has-results');
|
if (isHidden && searchHasResults) {
|
||||||
if (isHidden && searchHasResults) {
|
search.classList.remove('mobile-hidden');
|
||||||
search.classList.remove('mobile-hidden');
|
} else {
|
||||||
} else {
|
search.classList.add('mobile-hidden');
|
||||||
search.classList.add('mobile-hidden');
|
}
|
||||||
}
|
const content = docNav.querySelector('.content');
|
||||||
var content = document.querySelector('.doc-nav .content');
|
content.classList.toggle('hidden');
|
||||||
content.classList.toggle('hidden');
|
content.classList.toggle('show');
|
||||||
content.classList.toggle('show');
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDarkMode() {
|
function setupDarkMode() {
|
||||||
var html = document.getElementsByTagName('html')[0];
|
const html = document.querySelector('html');
|
||||||
var darkModeToggle = document.getElementById('dark-mode-toggle');
|
const darkModeToggle = document.getElementById('dark-mode-toggle');
|
||||||
darkModeToggle.addEventListener('click', function () {
|
darkModeToggle.addEventListener('click', () => {
|
||||||
html.classList.toggle('dark');
|
html.classList.toggle('dark');
|
||||||
var isDarkModeEnabled = html.classList.contains('dark');
|
const isDarkModeEnabled = html.classList.contains('dark');
|
||||||
localStorage.setItem('dark-mode', isDarkModeEnabled);
|
localStorage.setItem('dark-mode', isDarkModeEnabled);
|
||||||
darkModeToggle.setAttribute('aria-checked', isDarkModeEnabled)
|
darkModeToggle.setAttribute('aria-checked', isDarkModeEnabled);
|
||||||
});
|
});
|
||||||
// Check if css var() is supported and enable dark mode toggle
|
|
||||||
if (window.CSS && CSS.supports('color', 'var(--fake-var)')) {
|
|
||||||
darkModeToggle.style.visibility = 'unset';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSearch() {
|
function setupSearch() {
|
||||||
var searchInput = document.getElementById('search');
|
const searchInput = document.getElementById('search');
|
||||||
var onInputChange = debounce(function (e) {
|
const onInputChange = debounce((e) => {
|
||||||
var searchValue = e.target.value.toLowerCase();
|
const searchValue = e.target.value.toLowerCase();
|
||||||
var menu = document.querySelector('.doc-nav > .content');
|
const docNav = document.querySelector('.doc-nav');
|
||||||
var search = document.querySelector('.doc-nav > .search');
|
const menu = docNav.querySelector('.content');
|
||||||
if (searchValue === '') {
|
const search = docNav.querySelector('.search');
|
||||||
// reset to default
|
if (searchValue === '') {
|
||||||
menu.style.display = '';
|
// reset to default
|
||||||
if (!search.classList.contains('hidden')) {
|
menu.style.display = '';
|
||||||
search.classList.add('hidden');
|
if (!search.classList.contains('hidden')) {
|
||||||
search.classList.remove('has-results');
|
search.classList.add('hidden');
|
||||||
}
|
search.classList.remove('has-results');
|
||||||
} else if (searchValue.length >= 2) {
|
}
|
||||||
// search for less than 2 characters can display too much results
|
} else if (searchValue.length >= 2) {
|
||||||
search.innerHTML = '';
|
// search for less than 2 characters can display too much results
|
||||||
menu.style.display = 'none';
|
search.innerHTML = '';
|
||||||
if (search.classList.contains('hidden')) {
|
menu.style.display = 'none';
|
||||||
search.classList.remove('hidden');
|
if (search.classList.contains('hidden')) {
|
||||||
search.classList.remove('mobile-hidden');
|
search.classList.remove('hidden');
|
||||||
search.classList.add('has-results');
|
search.classList.remove('mobile-hidden');
|
||||||
}
|
search.classList.add('has-results');
|
||||||
// cache length for performance
|
}
|
||||||
var foundModule = false;
|
// cache length for performance
|
||||||
var searchModuleIndexLength = searchModuleIndex.length;
|
let foundModule = false;
|
||||||
var ul = document.createElement('ul');
|
const ul = document.createElement('ul');
|
||||||
search.appendChild(ul);
|
search.appendChild(ul);
|
||||||
for (var i = 0; i < searchModuleIndexLength; i++) {
|
for (const [i, title] of searchModuleIndex.entries()) {
|
||||||
// no toLowerCase needed because modules are always lowercase
|
// no toLowerCase needed because modules are always lowercase
|
||||||
var title = searchModuleIndex[i];
|
if (title.indexOf(searchValue) === -1) {
|
||||||
if (title.indexOf(searchValue) === -1) {
|
continue;
|
||||||
continue
|
}
|
||||||
}
|
foundModule = true;
|
||||||
foundModule = true;
|
// [description, link]
|
||||||
// [description, link]
|
const data = searchModuleData[i];
|
||||||
var data = searchModuleData[i];
|
const el = createSearchResult({
|
||||||
var description = data[0];
|
badge: 'module',
|
||||||
var link = data[1];
|
description: data[0],
|
||||||
var el = createSearchResult({
|
link: data[1],
|
||||||
link: link,
|
title: title,
|
||||||
title: title,
|
});
|
||||||
description: description,
|
ul.appendChild(el);
|
||||||
badge: 'module',
|
}
|
||||||
});
|
if (foundModule) {
|
||||||
ul.appendChild(el);
|
const hr = document.createElement('hr');
|
||||||
}
|
hr.classList.add('separator');
|
||||||
if (foundModule) {
|
search.appendChild(hr);
|
||||||
var hr = document.createElement('hr');
|
}
|
||||||
hr.classList.add('separator');
|
let results = [];
|
||||||
search.appendChild(hr);
|
for (const [i, title] of searchIndex.entries()) {
|
||||||
}
|
if (title.toLowerCase().indexOf(searchValue) === -1) {
|
||||||
var searchIndexLength = searchIndex.length;
|
continue;
|
||||||
var results = [];
|
}
|
||||||
for (var i = 0; i < searchIndexLength; i++) {
|
// [badge, description, link]
|
||||||
var title = searchIndex[i];
|
const data = searchData[i];
|
||||||
if (title.toLowerCase().indexOf(searchValue) === -1) {
|
results.push({
|
||||||
continue
|
badge: data[0],
|
||||||
}
|
description: data[1],
|
||||||
// [badge, description, link]
|
link: data[2],
|
||||||
var data = searchData[i];
|
title: data[3] + ' ' + title,
|
||||||
var badge = data[0];
|
});
|
||||||
var description = data[1];
|
}
|
||||||
var link = data[2];
|
results.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0));
|
||||||
var prefix = data[3];
|
const ul_ = document.createElement('ul');
|
||||||
results.push({
|
search.appendChild(ul_);
|
||||||
badge: badge,
|
results.forEach((result) => {
|
||||||
description: description,
|
const el = createSearchResult(result);
|
||||||
link: link,
|
ul_.appendChild(el);
|
||||||
title: prefix + ' ' + title,
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
results.sort(function (a, b) {
|
searchInput.addEventListener('input', onInputChange);
|
||||||
if (a.title < b.title) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.title > b.title) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
var ul = document.createElement('ul');
|
|
||||||
search.appendChild(ul);
|
|
||||||
for (var i = 0; i < results.length; i++) {
|
|
||||||
var result = results[i];
|
|
||||||
var el = createSearchResult(result);
|
|
||||||
ul.appendChild(el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
searchInput.addEventListener('input', onInputChange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSearchResult(data) {
|
function createSearchResult(data) {
|
||||||
var li = document.createElement('li');
|
const li = document.createElement('li');
|
||||||
li.classList.add('result');
|
li.classList.add('result');
|
||||||
var a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = data.link;
|
a.href = data.link;
|
||||||
a.classList.add('link');
|
a.classList.add('link');
|
||||||
li.appendChild(a);
|
li.appendChild(a);
|
||||||
var defintion = document.createElement('div');
|
const defintion = document.createElement('div');
|
||||||
defintion.classList.add('definition');
|
defintion.classList.add('definition');
|
||||||
a.appendChild(defintion);
|
a.appendChild(defintion);
|
||||||
if (data.description) {
|
if (data.description) {
|
||||||
var description = document.createElement('div');
|
const description = document.createElement('div');
|
||||||
description.classList.add('description');
|
description.classList.add('description');
|
||||||
description.textContent = data.description;
|
description.textContent = data.description;
|
||||||
a.appendChild(description);
|
a.appendChild(description);
|
||||||
}
|
}
|
||||||
var title = document.createElement('span');
|
const title = document.createElement('span');
|
||||||
title.classList.add('title');
|
title.classList.add('title');
|
||||||
title.textContent = data.title;
|
title.textContent = data.title;
|
||||||
defintion.appendChild(title);
|
defintion.appendChild(title);
|
||||||
var badge = document.createElement('badge');
|
const badge = document.createElement('badge');
|
||||||
badge.classList.add('badge');
|
badge.classList.add('badge');
|
||||||
badge.textContent = data.badge;
|
badge.textContent = data.badge;
|
||||||
defintion.appendChild(badge);
|
defintion.appendChild(badge);
|
||||||
return li;
|
return li;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupCollapse() {
|
function setupCollapse() {
|
||||||
var dropdownArrows = document.querySelectorAll('.dropdown-arrow');
|
const dropdownArrows = document.querySelectorAll('.dropdown-arrow');
|
||||||
for (var i = 0; i < dropdownArrows.length; i++) {
|
dropdownArrows.forEach((arrow) => {
|
||||||
var dropdownArrow = dropdownArrows[i];
|
arrow.addEventListener('click', (e) => {
|
||||||
dropdownArrow.addEventListener('click', function (e) {
|
const parent = e.target.parentElement.parentElement.parentElement;
|
||||||
var parent = e.target.parentElement.parentElement.parentElement;
|
parent.classList.toggle('open');
|
||||||
parent.classList.toggle('open');
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function debounce(func, timeout) {
|
function debounce(func, timeout) {
|
||||||
var timer;
|
let timer;
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
const next = () => func(...args);
|
const next = () => func(...args);
|
||||||
if (timer) {
|
if (timer) {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
}
|
}
|
||||||
timer = setTimeout(next, timeout > 0 ? timeout : 300);
|
timer = setTimeout(next, timeout > 0 ? timeout : 300);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('keypress', (ev) => {
|
document.addEventListener('keypress', (ev) => {
|
||||||
if (ev.key == '/') {
|
if (ev.key == '/') {
|
||||||
let search = document.getElementById('search');
|
const search = document.getElementById('search');
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
search.focus();
|
search.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
"short_name": "",
|
"short_name": "",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "/android-chrome-192x192.png",
|
"src": "/android-chrome-192x192.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "/android-chrome-512x512.png",
|
"src": "/android-chrome-512x512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"theme_color": "#ffffff",
|
"theme_color": "#ffffff",
|
||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"display": "standalone"
|
"display": "standalone"
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,72 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="x-ua-compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>{{ title }} | vdoc</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
|
||||||
|
<link rel="manifest" href="site.webmanifest" />
|
||||||
|
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5" />
|
||||||
|
<meta name="msapplication-TileColor" content="#da532c" />
|
||||||
|
<meta name="theme-color" content="#ffffff" />
|
||||||
|
{{ head_assets }}
|
||||||
|
</head>
|
||||||
|
|
||||||
<head>
|
<body>
|
||||||
<meta charset="UTF-8">
|
<div><a id="skip-to-content-link" href="#main-content">Skip to content</a></div>
|
||||||
<meta http-equiv="x-ua-compatible" content="IE=edge" />
|
<div id="page">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<header class="doc-nav hidden">
|
||||||
<title>{{ title }} | vdoc</title>
|
<div class="heading-container">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<div class="heading">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<div class="info">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
<div class="module">{{ head_name }}</div>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap" rel="stylesheet">
|
<div class="toggle-version-container">
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
|
<span>{{ version }}</span>
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
|
<div
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
|
id="dark-mode-toggle"
|
||||||
<link rel="manifest" href="site.webmanifest">
|
role="switch"
|
||||||
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
|
aria-checked="false"
|
||||||
<meta name="msapplication-TileColor" content="#da532c">
|
aria-label="Toggle dark mode"
|
||||||
<meta name="theme-color" content="#ffffff">
|
>
|
||||||
{{ head_assets }}
|
{{ light_icon }}{{ dark_icon }}
|
||||||
</head>
|
</div>
|
||||||
|
</div>
|
||||||
<body>
|
{{ menu_icon }}
|
||||||
<div><a id="skip-to-content-link" href="#main-content">Skip to content</a></div>
|
</div>
|
||||||
<div id="page">
|
<input type="text" id="search" placeholder="Search... (beta)" autocomplete="off" />
|
||||||
<header class="doc-nav hidden">
|
</div>
|
||||||
<div class="heading-container">
|
</div>
|
||||||
<div class="heading">
|
<nav class="search hidden"></nav>
|
||||||
<div class="info">
|
<nav class="content hidden">
|
||||||
<div class="module">{{ head_name }}</div>
|
<ul>
|
||||||
<div class="toggle-version-container">
|
{{ toc_links }}
|
||||||
<span>{{ version }}</span>
|
</ul>
|
||||||
<div id="dark-mode-toggle" role="switch" aria-checked="false" aria-label="Toggle dark mode">{{ light_icon }}{{ dark_icon }}</div>
|
</nav>
|
||||||
</div>
|
</header>
|
||||||
{{ menu_icon }}
|
<div class="doc-scrollview" id="main-content">
|
||||||
</div>
|
<div class="doc-container">
|
||||||
<input type="text" id="search" placeholder="Search... (beta)" autocomplete="off">
|
<div class="doc-content">
|
||||||
</div>
|
{{ contents }}
|
||||||
</div>
|
<div class="footer">{{ footer_content }}</div>
|
||||||
<nav class="search hidden"></nav>
|
</div>
|
||||||
<nav class="content hidden">
|
{{ right_content }}
|
||||||
<ul>
|
</div>
|
||||||
{{ toc_links }}
|
</div>
|
||||||
</ul>
|
</div>
|
||||||
</nav>
|
{{ footer_assets }}
|
||||||
</header>
|
<script async src="search_index.js"></script>
|
||||||
<div class="doc-scrollview" id="main-content">
|
</body>
|
||||||
<div class="doc-container">
|
|
||||||
<div class="doc-content">
|
|
||||||
{{ contents }}
|
|
||||||
<div class="footer">
|
|
||||||
{{ footer_content }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{ right_content }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{ footer_assets }}
|
|
||||||
<script async src="search_index.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
30
cmd/tools/vdoc/theme/normalize.css
vendored
30
cmd/tools/vdoc/theme/normalize.css
vendored
@ -91,24 +91,24 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
button,
|
button,
|
||||||
[type="button"],
|
[type='button'],
|
||||||
[type="reset"],
|
[type='reset'],
|
||||||
[type="submit"] {
|
[type='submit'] {
|
||||||
-webkit-appearance: button;
|
-webkit-appearance: button;
|
||||||
}
|
}
|
||||||
|
|
||||||
button::-moz-focus-inner,
|
button::-moz-focus-inner,
|
||||||
[type="button"]::-moz-focus-inner,
|
[type='button']::-moz-focus-inner,
|
||||||
[type="reset"]::-moz-focus-inner,
|
[type='reset']::-moz-focus-inner,
|
||||||
[type="submit"]::-moz-focus-inner {
|
[type='submit']::-moz-focus-inner {
|
||||||
border-style: none;
|
border-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:-moz-focusring,
|
button:-moz-focusring,
|
||||||
[type="button"]:-moz-focusring,
|
[type='button']:-moz-focusring,
|
||||||
[type="reset"]:-moz-focusring,
|
[type='reset']:-moz-focusring,
|
||||||
[type="submit"]:-moz-focusring {
|
[type='submit']:-moz-focusring {
|
||||||
outline: 1px dotted ButtonText;
|
outline: 1px dotted ButtonText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,23 +133,23 @@ textarea {
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
[type="checkbox"],
|
[type='checkbox'],
|
||||||
[type="radio"] {
|
[type='radio'] {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[type="number"]::-webkit-inner-spin-button,
|
[type='number']::-webkit-inner-spin-button,
|
||||||
[type="number"]::-webkit-outer-spin-button {
|
[type='number']::-webkit-outer-spin-button {
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
[type="search"] {
|
[type='search'] {
|
||||||
-webkit-appearance: textfield;
|
-webkit-appearance: textfield;
|
||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
[type="search"]::-webkit-search-decoration {
|
[type='search']::-webkit-search-decoration {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ const (
|
|||||||
allowed_formats = ['md', 'markdown', 'json', 'text', 'stdout', 'html', 'htm']
|
allowed_formats = ['md', 'markdown', 'json', 'text', 'stdout', 'html', 'htm']
|
||||||
vexe = os.getenv_opt('VEXE') or { @VEXE }
|
vexe = os.getenv_opt('VEXE') or { @VEXE }
|
||||||
vroot = os.dir(vexe)
|
vroot = os.dir(vexe)
|
||||||
tabs = ['\t\t', '\t\t\t\t\t\t', '\t\t\t\t\t\t\t']
|
|
||||||
)
|
)
|
||||||
|
|
||||||
enum OutputType {
|
enum OutputType {
|
||||||
|
Loading…
Reference in New Issue
Block a user