Skip to content

Commit d602722

Browse files
author
Marek Rozmus
committed
Merge branch 'docs_scripts'
2 parents cf21f02 + 85d4dc2 commit d602722

File tree

21 files changed

+1013
-7
lines changed

21 files changed

+1013
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ index.cjs.js
44
index.umd.js
55
**/*.d.ts
66
.coverage
7+
docs/dist

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,8 @@ Subtracts two values.
17091709
17101710
#### merge
17111711
1712+
Merges two objects deeply.
1713+
17121714
##### Type signature
17131715
17141716
<!-- prettier-ignore-start -->
@@ -1717,6 +1719,26 @@ Subtracts two values.
17171719
```
17181720
<!-- prettier-ignore-end -->
17191721
1722+
##### Examples
1723+
1724+
<!-- prettier-ignore-start -->
1725+
```javascript
1726+
merge({ a: 1, b: 3 }, {}); // ⇒ { a: 1, b: 3 }
1727+
```
1728+
1729+
```javascript
1730+
merge({ a: 1, b: 3 }, { b: 7 }); // ⇒ { a: 1, b: 7 }
1731+
```
1732+
1733+
```javascript
1734+
merge({ a: 1, b: 3 }, { b: { d: 8 } }); // ⇒ { a: 1, b: { d: 8 } }
1735+
```
1736+
1737+
```javascript
1738+
merge({ a: 1, b: { c: 3 } }, { b: { d: 8 } }); // ⇒ { a: 1, b: { c: 3, d: 8 } }
1739+
```
1740+
<!-- prettier-ignore-end -->
1741+
17201742
#### none
17211743
17221744
##### Type signature

array/any.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Checks if the given array is present and it is not empty (contains at least one
1111
<!-- prettier-ignore-end -->
1212

1313
## Examples
14-
1514
<!-- prettier-ignore-start -->
1615
```javascript
1716
any([]); // ⇒ false

docs/css/default.css

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
3+
Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
4+
5+
*/
6+
7+
.hljs {
8+
display: block;
9+
overflow-x: auto;
10+
padding: 0.5em;
11+
background: #F0F0F0;
12+
}
13+
14+
15+
/* Base color: saturation 0; */
16+
17+
.hljs,
18+
.hljs-subst {
19+
color: #444;
20+
}
21+
22+
.hljs-comment {
23+
color: #888888;
24+
}
25+
26+
.hljs-keyword,
27+
.hljs-attribute,
28+
.hljs-selector-tag,
29+
.hljs-meta-keyword,
30+
.hljs-doctag,
31+
.hljs-name {
32+
font-weight: bold;
33+
}
34+
35+
36+
/* User color: hue: 0 */
37+
38+
.hljs-type,
39+
.hljs-string,
40+
.hljs-number,
41+
.hljs-selector-id,
42+
.hljs-selector-class,
43+
.hljs-quote,
44+
.hljs-template-tag,
45+
.hljs-deletion {
46+
color: #880000;
47+
}
48+
49+
.hljs-title,
50+
.hljs-section {
51+
color: #880000;
52+
font-weight: bold;
53+
}
54+
55+
.hljs-regexp,
56+
.hljs-symbol,
57+
.hljs-variable,
58+
.hljs-template-variable,
59+
.hljs-link,
60+
.hljs-selector-attr,
61+
.hljs-selector-pseudo {
62+
color: #BC6060;
63+
}
64+
65+
66+
/* Language color: hue: 90; */
67+
68+
.hljs-literal {
69+
color: #78A960;
70+
}
71+
72+
.hljs-built_in,
73+
.hljs-bullet,
74+
.hljs-code,
75+
.hljs-addition {
76+
color: #397300;
77+
}
78+
79+
80+
/* Meta color: hue: 200 */
81+
82+
.hljs-meta {
83+
color: #1f7199;
84+
}
85+
86+
.hljs-meta-string {
87+
color: #4d99bf;
88+
}
89+
90+
91+
/* Misc effects */
92+
93+
.hljs-emphasis {
94+
font-style: italic;
95+
}
96+
97+
.hljs-strong {
98+
font-weight: bold;
99+
}

docs/css/docs.css

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
body {
2+
font-family: "Times New Roman", Times, serif;
3+
height: 100vh;
4+
overflow: hidden;
5+
margin: 0;
6+
padding: 0;
7+
}
8+
9+
.examples .content {
10+
position: relative;
11+
}
12+
13+
.btn-repl {
14+
color: #0275d8;
15+
font-size: 16px;
16+
position: absolute;
17+
right: 4px;
18+
cursor: pointer;
19+
text-decoration: underline;
20+
margin: 4px;
21+
}
22+
23+
ul {
24+
list-style-type: circle;
25+
}
26+
27+
.std-item {
28+
background: #fafafa;
29+
border: 0.5px solid lightgray;
30+
padding: 8px 16px;
31+
border-radius: 5px;
32+
margin-bottom: 16px;
33+
}
34+
35+
.std-item h2 {
36+
margin-top: 4px;
37+
}
38+
39+
code {
40+
border-radius: 5px;
41+
}
42+
43+
.module-name {
44+
margin-bottom: 4px;
45+
}
46+
47+
.module-name,
48+
.name {
49+
font-family: "Courier New", Courier, monospace;
50+
}
51+
52+
.module-name.selected > a,
53+
.name > a {
54+
color: #0275d8;
55+
}
56+
57+
.repl {
58+
margin-left: 16px;
59+
}
60+
61+
a {
62+
text-decoration: none;
63+
color: black;
64+
}
65+
66+
.toc {
67+
background: #fafafa;
68+
border: 0.5px solid lightgray;
69+
border-radius: 5px;
70+
padding: 8px 16px;
71+
padding-bottom: 16px;
72+
display: block;
73+
position: absolute;
74+
height: auto;
75+
bottom: 0;
76+
top: 0;
77+
left: 0;
78+
margin: 16px;
79+
width: 208px;
80+
overflow: auto;
81+
}
82+
83+
.row > .content {
84+
display: block;
85+
position: absolute;
86+
height: auto;
87+
bottom: 0;
88+
top: 0;
89+
left: 256px;
90+
right: 0;
91+
margin: 16px;
92+
overflow: auto;
93+
}
94+
95+
.list {
96+
overflow: hidden;
97+
}
98+
99+
.toc-item {
100+
font-family: "Courier New", Courier, monospace;
101+
}
102+
103+
.toc-item.selected > a {
104+
font-weight: bold;
105+
color: #0275d8;
106+
font-size: 18px;
107+
}
108+
109+
.breadcrumbs {
110+
font-size: 16px;
111+
padding-top: 8px;
112+
}
113+
114+
.breadcrumbs > a {
115+
color: #0275d8;
116+
}
117+
118+
.breadcrumbs > a:hover {
119+
color: black;
120+
}
121+
122+
.breadcrumbs > span {
123+
padding: 0 4px;
124+
}
125+
126+
#searchInput {
127+
font-size: 16px;
128+
padding: 4px;
129+
box-sizing: border-box;
130+
width: 100%;
131+
border: none;
132+
border-bottom: solid 1px gray;
133+
}
134+
135+
#searchInput:focus {
136+
outline: none;
137+
border-bottom-color: #0275d8;
138+
}

docs/docsHtml.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* eslint-env node */
2+
// eslint-disable console
3+
import { promises } from "fs";
4+
import path from "path";
5+
6+
import filesPaths, { docsPath, outPath, copyDir } from "./utils/io.js";
7+
import pageTemplate from "./templates/page.js";
8+
import tocContent from "./templates/toc.js";
9+
import generateModuleDocs from "./templates/module.js";
10+
11+
const {
12+
writeFile: writeFileAsync,
13+
readFile: readFileAsync,
14+
mkdir: mkdirAsync,
15+
rmdir: rmdirAsync
16+
} = promises;
17+
18+
let data = {};
19+
20+
const addData = (filePath, fileData) => {
21+
const pathParts = path
22+
.dirname(filePath)
23+
.slice(process.cwd().length)
24+
.split(path.sep)
25+
.filter(x => x != "");
26+
27+
const moduleName = [...pathParts].pop();
28+
29+
if (data[moduleName]) {
30+
data[moduleName].functions.push(fileData);
31+
} else {
32+
data[moduleName] = {
33+
pathParts,
34+
functions: [fileData]
35+
};
36+
}
37+
};
38+
39+
const main = async cwd => {
40+
console.log("Clearing dist...");
41+
const outputPath = outPath();
42+
43+
await rmdirAsync(outputPath, { recursive: true });
44+
await mkdirAsync(outputPath, { recursive: true });
45+
await copyDir(docsPath("css"), outPath("css"));
46+
await copyDir(docsPath("scripts"), outPath("scripts"));
47+
48+
console.log("Generating html documentation files...");
49+
50+
for (const path of filesPaths(cwd)) {
51+
const content = await readFileAsync(path, "utf8");
52+
const data = JSON.parse(content);
53+
54+
addData(path, data);
55+
}
56+
57+
const toc = tocContent(data);
58+
59+
let mainPageContent = "";
60+
61+
for (const moduleName of Object.keys(data)) {
62+
const moduleData = data[moduleName];
63+
64+
mainPageContent += await generateModuleDocs({
65+
data: moduleData,
66+
toc,
67+
name: moduleName
68+
});
69+
}
70+
71+
await writeFileAsync(
72+
outPath("index.html"),
73+
pageTemplate({ content: mainPageContent, toc })
74+
);
75+
};
76+
77+
main(process.cwd());

docs/scripts/docs.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// eslint-disable-next-line no-unused-vars
2+
function tryInREPL(event, scope) {
3+
var target = event.target;
4+
var isReplRun = target.matches(".btn-repl");
5+
6+
if (!isReplRun) {
7+
return;
8+
}
9+
10+
var codeElement = target.parentNode.children[1];
11+
12+
var parent = target.parentNode;
13+
var container = target.parentNode.nextElementSibling;
14+
15+
parent.parentNode.removeChild(parent);
16+
17+
// eslint-disable-next-line no-undef
18+
RunKit.createNotebook({
19+
element: container,
20+
nodeVersion: "11",
21+
preamble: `const std = require ("@sandstreamdev/std/index.cjs.js");\nconst ${scope} = std;`,
22+
source: codeElement.textContent
23+
});
24+
}

0 commit comments

Comments
 (0)