Book style tweaks
diff --git a/book/book.toml b/book/book.toml
index fe8b5fc..d8928fb 100644
--- a/book/book.toml
+++ b/book/book.toml
@@ -8,8 +8,11 @@
[build]
build-dir = "build"
+create-missing = false
[output.html]
additional-css = ["css/cxx.css"]
cname = "cxx.rs"
git-repository-url = "https://github.com/dtolnay/cxx"
+playground = { copyable = false }
+print = { enable = false }
diff --git a/book/build.js b/book/build.js
index e7ec435..091d4ce 100755
--- a/book/build.js
+++ b/book/build.js
@@ -14,6 +14,11 @@
</a>\
</li>`;
+const htmljs = `\
+var html = document.querySelector('html');
+html.classList.remove('no-js');
+html.classList.add('js');`;
+
const dirs = ['build'];
while (dirs.length) {
const dir = dirs.pop();
@@ -32,7 +37,11 @@
const index = fs.readFileSync(path, 'utf8');
const $ = cheerio.load(index, { decodeEntities: false });
+ $('script:nth-of-type(3)').text(htmljs);
$('nav#sidebar ol.chapter').append(githublink);
+ $('head link[href="tomorrow-night.css"]').attr('disabled', true);
+ $('head link[href="ayu-highlight.css"]').attr('disabled', true);
+ $('button#theme-toggle').attr('style', 'display:none');
$('pre code').each(function () {
const node = $(this);
const langClass = node.attr('class').split(' ', 2)[0];
@@ -44,6 +53,7 @@
const boring = lines.map((line) =>
line.includes('<span class="boring">')
);
+ const ellipsis = lines.map((line) => line.includes('// ...'));
const target = entities.decode(node.text());
const highlighted = hljs.highlight(lang, target).value;
const result = highlighted
@@ -51,14 +61,21 @@
.map(function (line, i) {
if (boring[i]) {
line = '<span class="boring">' + line;
+ } else if (ellipsis[i]) {
+ line = '<span class="ellipsis">' + line;
}
- if (i > 0 && boring[i - 1]) {
+ if (i > 0 && (boring[i - 1] || ellipsis[i - 1])) {
line = '</span>' + line;
}
return line;
})
.join('\n');
- node.text(result).removeClass(langClass).addClass('hidelines');
+ node.text(result);
+ node.removeClass(langClass);
+ if (!node.hasClass('focuscomment')) {
+ node.addClass('hidelines');
+ node.addClass('hide-boring');
+ }
});
$('code').each(function () {
$(this).addClass('hljs');
@@ -68,3 +85,10 @@
fs.writeFileSync(path, out);
});
}
+
+fs.copyFileSync('build/highlight.css', 'build/tomorrow-night.css');
+fs.copyFileSync('build/highlight.css', 'build/ayu-highlight.css');
+
+var bookjs = fs.readFileSync('build/book.js', 'utf8');
+bookjs = bookjs.replace('set_theme(theme, false);', '');
+fs.writeFileSync('build/book.js', bookjs);
diff --git a/book/css/cxx.css b/book/css/cxx.css
index 2a167bc..647f4f7 100644
--- a/book/css/cxx.css
+++ b/book/css/cxx.css
@@ -1,7 +1,36 @@
-.no-js .boring {
+:root {
+ --sidebar-width: 310px;
+}
+
+.badges img {
+ margin: 0 7px 7px 0;
+}
+
+.badges {
+ margin: 16px 0 120px;
+}
+
+.boring {
+ opacity: 0.5;
+}
+
+.no-js code:not(.focuscomment) .boring {
display: none;
}
+.js code:not(.hide-boring) .ellipsis {
+ display: none;
+}
+
+.focuscomment .hljs-comment {
+ font-weight: bold;
+ color: black;
+}
+
+.focuscomment .boring {
+ opacity: 0.5;
+}
+
nav.sidebar li.part-title i.fa-github {
font-size: 20px;
padding-right: 5px;
@@ -9,3 +38,7 @@
position: relative;
top: 1px;
}
+
+.sidebar .sidebar-scrollbox {
+ padding: 10px 0 10px 10px;
+}
diff --git a/book/diagram/overview.ascii b/book/diagram/overview.ascii
index 06323ca..dd1c4b9 100644
--- a/book/diagram/overview.ascii
+++ b/book/diagram/overview.ascii
@@ -1,6 +1,6 @@
.-----------------------------.
| #[cxx::bridge] mod |
- | definitions and declarations |
+ | description of boundary |
'--------------+--------------'
|
|
diff --git a/book/diagram/overview.svg b/book/diagram/overview.svg
index 69baaf2..c551687 100644
--- a/book/diagram/overview.svg
+++ b/book/diagram/overview.svg
@@ -94,9 +94,9 @@
<text x="426" y="188" >C++ bindings</text>
<text x="266" y="28" >#[cxx::bridge]</text>
<text x="394" y="28" >mod</text>
- <text x="234" y="44" >definitions</text>
- <text x="330" y="44" >and</text>
- <text x="362" y="44" >declarations</text>
+ <text x="250" y="44" >description</text>
+ <text x="346" y="44" >of</text>
+ <text x="370" y="44" >boundary</text>
<line x1="220" y1="120" x2="220" y2="160" class="solid end_marked_arrow"></line>
<line x1="476" y1="120" x2="476" y2="160" class="solid end_marked_arrow"></line>
<text x="74" y="140" >Safe</text>