Skip to content

Commit 8427297

Browse files
Pages for ADRs and "About" page
Adds pages for ADRs with code styling and mermaid diagrams. About page has some minimal information about the project that can be expanded in the future. Signed-off-by: Rodrigo Pinto <[email protected]>
1 parent 7668c88 commit 8427297

20 files changed

+911
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
!examples/*/scripts/
66
*.log
77
*.tsbuildinfo
8+
.DS_Store
89
.browser_modules/
910
/.venv/
1011
/packages/base/lib/

doc/web-doc/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# LC_COLLATE=C sort .gitignore
2-
!.env.example
32
.DS_Store
43
.env
54
.env.*
65
/.svelte-kit
76
/build
87
/package
8+
doc-sources
99
node_modules
1010
vite.config.js.timestamp-*
1111
vite.config.ts.timestamp-*

doc/web-doc/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
doc-sources
23
node_modules
34
/build
45
/.svelte-kit

doc/web-doc/doc-loader.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const errorCallback = (err) => {
1313
const comparisonOptions = {
1414
excludeFilter: '.DS_Store',
1515
compareSize: true,
16-
compareContent: true
16+
compareContent: true
1717
};
1818

1919
// Sanitizer of markdown files
@@ -46,7 +46,7 @@ const processLineByLine = async (file) => {
4646
result += line + '\n';
4747
}
4848

49-
if (line.includes('```mermaid')) {
49+
if (line.includes('```mermaid')) {
5050
mermaid = true;
5151
}
5252
});
@@ -62,10 +62,10 @@ const processLineByLine = async (file) => {
6262
// Compare folders
6363

6464
if (!fs.existsSync('doc-sources')) {
65-
fs.mkdirSync('doc-sources');
66-
fs.mkdirSync(dest);
65+
fs.mkdirSync('doc-sources');
66+
fs.mkdirSync(dest);
6767
} else if (!fs.existsSync(dest)) {
68-
fs.mkdirSync(dest);
68+
fs.mkdirSync(dest);
6969
}
7070

7171
const comparison = compareSync(src, dest, comparisonOptions);
@@ -76,10 +76,10 @@ if (!comparison.same) {
7676
comparison.diffSet.forEach(async (dif) => {
7777
if ((dif.state === 'left' || dif.state === 'distinct') && dif.path1 === src) {
7878
if (dif.type1 === 'file' && dif.name1.slice(-3) === '.md') {
79-
// Remove outdated file
80-
if (dif.state === 'distinct') {
81-
fs.rmSync(dest + dif.name2, { force: true })
82-
}
79+
// Remove outdated file
80+
if (dif.state === 'distinct') {
81+
fs.rmSync(dest + dif.name2, { force: true });
82+
}
8383

8484
// Sanitize Markdown files
8585
const file = fs.createReadStream(src + dif.name1, 'utf8');

doc/web-doc/mdsvex.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import remarkMermaid from '@ysuzuki19/remark-mermaid';
2+
3+
const config = {
4+
extensions: ['.svelte.md', '.md', '.svx'],
5+
6+
smartypants: {
7+
dashes: 'oldschool'
8+
},
9+
10+
remarkPlugins: [remarkMermaid],
11+
rehypePlugins: []
12+
};
13+
14+
export default config;

doc/web-doc/src/lib/components/Header.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<header>
88
<div class="corner">
9-
<a href="https://projects.eclipse.org/projects/tools.tracecompass">
9+
<a href="https://projects.eclipse.org/projects/tools.tracecompass">
1010
<img src={logo} alt="Trace Compass" />
1111
</a>
1212
</div>

doc/web-doc/src/lib/components/Sidebar.svelte

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script>
22
import { page } from '$app/stores';
33
import { goto } from '$app/navigation';
4+
5+
export let adrs;
6+
let showAdrs = false;
47
</script>
58

69
<div class="sidebar">
@@ -11,12 +14,27 @@
1114
<li aria-current={$page.url.pathname === '/about' ? 'page' : undefined}>
1215
<button on:click={() => goto('/about')}>About</button>
1316
</li>
17+
<li>
18+
<button class:selected={showAdrs} on:click={() => (showAdrs = !showAdrs)}>ADRs</button>
19+
</li>
20+
{#if showAdrs}
21+
{#each adrs as adr}
22+
<li aria-current={$page.url.pathname === '/adr/' + adr.slug ? 'page' : undefined}>
23+
<button class="adr">
24+
<a href={'/adr/' + adr.slug} target="_self">
25+
<div class="link-holder">{adr.slug}</div>
26+
</a>
27+
</button>
28+
</li>
29+
{/each}
30+
{/if}
1431
</ul>
1532
</div>
1633

1734
<style>
1835
.sidebar {
1936
width: 10em;
37+
min-width: 10em;
2038
}
2139
2240
ul {
@@ -31,6 +49,37 @@
3149
button {
3250
width: 100%;
3351
height: 100%;
34-
background: none;
52+
}
53+
54+
button.adr {
55+
display: flex;
56+
padding: 0;
57+
}
58+
59+
button.adr a {
60+
width: 100%;
61+
height: 100%;
62+
display: flex;
63+
color: black;
64+
text-decoration: none;
65+
}
66+
67+
button.adr a:visited,
68+
button.adr a:link,
69+
button.adr a:focus {
70+
color: black;
71+
}
72+
73+
button.selected {
74+
background: lightgrey;
75+
border-width: 0;
76+
}
77+
78+
button:hover {
79+
cursor: pointer;
80+
}
81+
82+
.link-holder {
83+
margin: auto;
3584
}
3685
</style>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const allAdrFiles = import.meta.glob('/doc-sources/adr-source/*.md');
2+
const iterableAdrFiles = Object.entries(allAdrFiles);
3+
4+
export const getAdrsContent = async () => {
5+
const allAdrs = await Promise.all(
6+
iterableAdrFiles.map(async ([path, resolver]) => {
7+
const element = await resolver();
8+
const metadata = element.metadata;
9+
const content = element.default.render();
10+
const slug = path.slice(0, -3).split('/').pop();
11+
12+
return {
13+
metadata,
14+
slug,
15+
path,
16+
content
17+
};
18+
})
19+
);
20+
21+
return allAdrs;
22+
};
23+
24+
export const getAdr = async (slug) => {
25+
const adr = iterableAdrFiles?.filter(([path]) => {
26+
const fileSlug = path.slice(0, -3).split('/').pop();
27+
28+
return fileSlug === slug;
29+
});
30+
31+
if (adr.length > 0) {
32+
const resolver = adr[0][1];
33+
const element = await resolver();
34+
console.log('resolver', element);
35+
// const content = element.default.render()
36+
37+
// return content
38+
}
39+
40+
return adr;
41+
};
42+
43+
export const getOneAdr = async (slug) => {
44+
const allAdrs = await Promise.all(
45+
iterableAdrFiles.map(async ([path, resolver]) => {
46+
const fileSlug = path.slice(0, -3).split('/').pop();
47+
let content = 'empty';
48+
if (fileSlug === slug) {
49+
console.log('equal', slug, path, resolver);
50+
const element = await resolver();
51+
content = element.default.render();
52+
}
53+
54+
return {
55+
content
56+
};
57+
})
58+
);
59+
60+
console.log('all adrs', allAdrs);
61+
return allAdrs;
62+
};

0 commit comments

Comments
 (0)