mirror of
https://github.com/twirl/The-API-Book.git
synced 2025-05-25 22:08:06 +02:00
minor changes & fresh builds
This commit is contained in:
parent
c8a36c8634
commit
943f929d4d
@ -1,27 +1,50 @@
|
|||||||
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
import {
|
||||||
|
readFileSync,
|
||||||
|
writeFileSync,
|
||||||
|
readdirSync,
|
||||||
|
existsSync,
|
||||||
|
mkdirSync
|
||||||
|
} from 'fs';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
import puppeteer from 'puppeteer';
|
import puppeteer from 'puppeteer';
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const dir = process.cwd();
|
const dir = process.cwd();
|
||||||
|
const langs = (args[1] || 'en,ru').split(',');
|
||||||
|
const graphDir = resolve(dir, 'src', 'graphs');
|
||||||
|
const tmpDir = resolve(graphDir, 'tmp');
|
||||||
|
const srcDir = resolve(dir, 'src');
|
||||||
|
|
||||||
if (args[0] == 'l10n') {
|
if (!existsSync(tmpDir)) {
|
||||||
buildL10N(dir, (args[1] || 'en,ru').split(','));
|
mkdirSync(tmpDir);
|
||||||
} else {
|
}
|
||||||
buildGraphs(dir, (args[0] || 'en,ru').split(','), args[1]);
|
const targets = args[2]
|
||||||
|
? [args[2] + '.yaml']
|
||||||
|
: readdirSync(graphDir).filter((i) => i.endsWith('.yaml'));
|
||||||
|
|
||||||
|
build(langs, targets, srcDir, graphDir, tmpDir).then(
|
||||||
|
() => process.exit(0),
|
||||||
|
(e) => {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
async function build(langs, targets, srcDir, graphDir, tmpDir) {
|
||||||
|
await buildL10n(langs, srcDir, tmpDir);
|
||||||
|
await buildGraphs(langs, targets, graphDir, tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildL10N(dir, langs) {
|
async function buildL10n(langs, srcDir, tmpDir) {
|
||||||
const l10n = langs.reduce((l10n, lang) => {
|
const l10n = langs.reduce((l10n, lang) => {
|
||||||
const l10nFile = resolve(dir, 'src', lang, 'l10n.json');
|
const l10nFile = resolve(srcDir, lang, 'l10n.json');
|
||||||
const contents = JSON.parse(readFileSync(l10nFile).toString('utf-8'));
|
const contents = JSON.parse(readFileSync(l10nFile).toString('utf-8'));
|
||||||
l10n[lang] = JSON.stringify(contents);
|
l10n[lang] = JSON.stringify(contents);
|
||||||
return l10n;
|
return l10n;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
resolve(dir, 'src', 'graphs', 'l10n.js'),
|
resolve(tmpDir, 'l10n.js'),
|
||||||
`(function(global){global.l10n={${Object.entries(l10n)
|
`(function(global){global.l10n={${Object.entries(l10n)
|
||||||
.map(
|
.map(
|
||||||
([lang, content]) =>
|
([lang, content]) =>
|
||||||
@ -31,17 +54,19 @@ async function buildL10N(dir, langs) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildGraphs(dir, langs, source) {
|
async function buildGraphs(langs, targets, graphDir, tmpDir) {
|
||||||
const srcDir = resolve(dir, 'src', 'graphs');
|
const tasks = langs.reduce(
|
||||||
const sources = source
|
(tasks, lang) =>
|
||||||
? [source]
|
tasks.concat(
|
||||||
: readdirSync(srcDir)
|
targets.map((target) => {
|
||||||
.filter((file) => file.slice(-3) == '.js' && file != 'l10n.js')
|
lang, target;
|
||||||
.map((file) => file.slice(0, file.length - 3))
|
})
|
||||||
.sort();
|
),
|
||||||
const indexFileUrl = pathToFileURL(
|
[]
|
||||||
resolve(dir, 'src', 'graphs', 'index.html')
|
|
||||||
);
|
);
|
||||||
|
return Promise.all(tasks.map(({lang, target}) => {
|
||||||
|
const yaml = readFileSync(resolve(graphDir, target))
|
||||||
|
});
|
||||||
|
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
console.log(`Building ${source}…`);
|
console.log(`Building ${source}…`);
|
||||||
|
BIN
docs/API.en.epub
BIN
docs/API.en.epub
Binary file not shown.
BIN
docs/API.en.pdf
BIN
docs/API.en.pdf
Binary file not shown.
BIN
docs/API.ru.epub
BIN
docs/API.ru.epub
Binary file not shown.
BIN
docs/API.ru.pdf
BIN
docs/API.ru.pdf
Binary file not shown.
@ -119,8 +119,16 @@ img.header {
|
|||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
padding-top: 0.4em;
|
padding-top: 0.4em;
|
||||||
|
color: gray;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.about-me aside a, .about-me aside a:visited {
|
||||||
|
color: inherit;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.about-me aside img {
|
.about-me aside img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
<p>Source code available at <a href="https://github.com/twirl/The-API-Book">github.com/twirl/The-API-Book</a></p>
|
<p>Source code available at <a href="https://github.com/twirl/The-API-Book">github.com/twirl/The-API-Book</a></p>
|
||||||
<h3><a name="about-author">About the Author</a></h3>
|
<h3><a name="about-author">About the Author</a></h3>
|
||||||
<section class="about-me">
|
<section class="about-me">
|
||||||
<aside><img src="https://konstantinov.cc/static/me.png"/></aside>
|
<aside><img src="https://konstantinov.cc/static/me.png"/><br/>Photo by <a href="http://linkedin.com/in/zloylos/">Denis Hananein</a></aside>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p>Sergey Konstantinov has been working with APIs for more than a decade. He started his career as a software engineer in the Maps API division at Yandex and eventually became the head of the service, being responsible for both technical architecture and product management.</p>
|
<p>Sergey Konstantinov has been working with APIs for more than a decade. He started his career as a software engineer in the Maps API division at Yandex and eventually became the head of the service, being responsible for both technical architecture and product management.</p>
|
||||||
<p>During this tenure, Sergey got a unique experience in building world-class APIs with a daily audience of tens of millions, planning roadmaps for such a service, and giving numerous public speeches. He also worked for a year and a half as a member of the W3C Technical Architecture Group.</p>
|
<p>During this tenure, Sergey got a unique experience in building world-class APIs with a daily audience of tens of millions, planning roadmaps for such a service, and giving numerous public speeches. He also worked for a year and a half as a member of the W3C Technical Architecture Group.</p>
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
<p>Исходный код доступен на <a href="https://github.com/twirl/The-API-Book">github.com/twirl/The-API-Book</a></p>
|
<p>Исходный код доступен на <a href="https://github.com/twirl/The-API-Book">github.com/twirl/The-API-Book</a></p>
|
||||||
<h3><a name="about-author">Об авторе</a></h3>
|
<h3><a name="about-author">Об авторе</a></h3>
|
||||||
<section class="about-me">
|
<section class="about-me">
|
||||||
<aside><img src="https://konstantinov.cc/static/me.png"/></aside>
|
<aside><img src="https://konstantinov.cc/static/me.png"/><br/>Фото: <a href="http://linkedin.com/in/zloylos/">Denis Hananein</a></aside>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p>Сергей Константинов работает с API уже больше десятилетия. Он начинал свою карьеру разработчиком в подразделении API Яндекс.Карт, и со временем стал руководителем всего сервиса, отвечая и за техническую, и за продуктовую составляющую.</p>
|
<p>Сергей Константинов работает с API уже больше десятилетия. Он начинал свою карьеру разработчиком в подразделении API Яндекс.Карт, и со временем стал руководителем всего сервиса, отвечая и за техническую, и за продуктовую составляющую.</p>
|
||||||
<p>За это время Сергей получил уникальный опыт построения API мирового уровня с дневной аудторией в десятки миллионов человек, планирования роадмапов для такого продукта и многочисленных публичных выступлений. Он также проработал полтора года в составе Технической архитектурной группы W3C.</p>
|
<p>За это время Сергей получил уникальный опыт построения API мирового уровня с дневной аудторией в десятки миллионов человек, планирования роадмапов для такого продукта и многочисленных публичных выступлений. Он также проработал полтора года в составе Технической архитектурной группы W3C.</p>
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
"<p>Sergey Konstantinov has been working with APIs for more than a decade. He started his career as a software engineer in the Maps API division at Yandex and eventually became the head of the service, being responsible for both technical architecture and product management.</p>",
|
"<p>Sergey Konstantinov has been working with APIs for more than a decade. He started his career as a software engineer in the Maps API division at Yandex and eventually became the head of the service, being responsible for both technical architecture and product management.</p>",
|
||||||
"<p>During this tenure, Sergey got a unique experience in building world-class APIs with a daily audience of tens of millions, planning roadmaps for such a service, and giving numerous public speeches. He also worked for a year and a half as a member of the W3C Technical Architecture Group.</p>",
|
"<p>During this tenure, Sergey got a unique experience in building world-class APIs with a daily audience of tens of millions, planning roadmaps for such a service, and giving numerous public speeches. He also worked for a year and a half as a member of the W3C Technical Architecture Group.</p>",
|
||||||
"<p>After nine years in Maps, Sergey switched to technical-lead roles in other departments and companies, leading integration efforts and being responsible for the technical architecture of entire business units. Today, Sergey lives in Tallinn, Estonia, and works as a staff software engineer at Bolt.</p>"
|
"<p>After nine years in Maps, Sergey switched to technical-lead roles in other departments and companies, leading integration efforts and being responsible for the technical architecture of entire business units. Today, Sergey lives in Tallinn, Estonia, and works as a staff software engineer at Bolt.</p>"
|
||||||
]
|
],
|
||||||
|
"imageCredit": "Photo by <a href=\"http://linkedin.com/in/zloylos/\">Denis Hananein</a>"
|
||||||
},
|
},
|
||||||
"landingFile": "index.html",
|
"landingFile": "index.html",
|
||||||
"url": "https://twirl.github.io/The-API-Book/",
|
"url": "https://twirl.github.io/The-API-Book/",
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
"<p>Сергей Константинов работает с API уже больше десятилетия. Он начинал свою карьеру разработчиком в подразделении API Яндекс.Карт, и со временем стал руководителем всего сервиса, отвечая и за техническую, и за продуктовую составляющую.</p>",
|
"<p>Сергей Константинов работает с API уже больше десятилетия. Он начинал свою карьеру разработчиком в подразделении API Яндекс.Карт, и со временем стал руководителем всего сервиса, отвечая и за техническую, и за продуктовую составляющую.</p>",
|
||||||
"<p>За это время Сергей получил уникальный опыт построения API мирового уровня с дневной аудторией в десятки миллионов человек, планирования роадмапов для такого продукта и многочисленных публичных выступлений. Он также проработал полтора года в составе Технической архитектурной группы W3C.</p>",
|
"<p>За это время Сергей получил уникальный опыт построения API мирового уровня с дневной аудторией в десятки миллионов человек, планирования роадмапов для такого продукта и многочисленных публичных выступлений. Он также проработал полтора года в составе Технической архитектурной группы W3C.</p>",
|
||||||
"<p>После девяти лет в Картах Сергей переключился на технические роли в других департаментах и компаниях, занимаясь интеграционными проектами и будучи ответственным за техническую архитектуру целых продуктов компании. Сегодня Сергей живёт в Таллинне, Эстония, и работает ведущим инженером в компании Bolt.</p>"
|
"<p>После девяти лет в Картах Сергей переключился на технические роли в других департаментах и компаниях, занимаясь интеграционными проектами и будучи ответственным за техническую архитектуру целых продуктов компании. Сегодня Сергей живёт в Таллинне, Эстония, и работает ведущим инженером в компании Bolt.</p>"
|
||||||
]
|
],
|
||||||
|
"imageCredit": "Фото: <a href=\"http://linkedin.com/in/zloylos/\">Denis Hananein</a>"
|
||||||
},
|
},
|
||||||
"url": "https://twirl.github.io/The-API-Book/index.ru.html",
|
"url": "https://twirl.github.io/The-API-Book/index.ru.html",
|
||||||
"favicon": "/img/favicon.png",
|
"favicon": "/img/favicon.png",
|
||||||
|
@ -146,7 +146,9 @@ const templates = (module.exports = {
|
|||||||
}</a></p>
|
}</a></p>
|
||||||
<h3><a name="about-author">${l10n.aboutMe.title}</a></h3>
|
<h3><a name="about-author">${l10n.aboutMe.title}</a></h3>
|
||||||
<section class="about-me">
|
<section class="about-me">
|
||||||
<aside><img src="https://konstantinov.cc/static/me.png"/></aside>
|
<aside><img src="https://konstantinov.cc/static/me.png"/><br/>${
|
||||||
|
l10n.aboutMe.imageCredit
|
||||||
|
}</aside>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
${l10n.aboutMe.content.join('\n')}</div>
|
${l10n.aboutMe.content.join('\n')}</div>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user