Skip to content

Commit 2f783c2

Browse files
committed
add "edit page on github" button for dev docs
1 parent f37d7a8 commit 2f783c2

16 files changed

+103
-58
lines changed

cli/dist/prebuild.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const getDocsData = (allFiles) => {
3838
const href = createUrlFromFilePath(fullPath);
3939
const text = createNameFromFilePath(fullPath);
4040
const folderName = getFolderFromPath(fullPath);
41-
const output = {text, href};
41+
const output = { text, href };
4242
if (typeof folders[folderName] === "undefined") {
4343
folders[folderName] = output;
4444
} else {
@@ -59,7 +59,7 @@ const creatTableOfContents = (pages) => {
5959
fs.writeFileSync(TOC_OUTPUT_PATH, contents);
6060
};
6161
const removePreviousDocs = () => {
62-
fs.rmdirSync(DOCS_PUBLISH_PATH, {recursive: true});
62+
fs.rmdirSync(DOCS_PUBLISH_PATH, { recursive: true });
6363
};
6464
const copyDocsFiles = (files) => {
6565
const docsTemplateContents = fs.readFileSync(DOCS_TEMPLATE_PATH).toString();

cli/src/templates/docs-layout.svelte

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
<script lang="ts">
22
import { page } from '$app/stores'
33
import TableOfContents from '@nick-mazuk/ui-svelte/src/components/table-of-contents/table-of-contents.svelte'
4+
import Button from '@nick-mazuk/ui-svelte/src/elements/button/button.svelte'
5+
import Github from '@nick-mazuk/ui-svelte/src/elements/icon/github.svelte'
6+
import Spacer from '@nick-mazuk/ui-svelte/src/utilities/spacer/spacer.svelte'
47
58
import { libraryPages } from '../../lib/lib/library-pages'
9+
10+
const githubPrefix = 'https://github.com/Nick-Mazuk/jw-lua-scripts/blob/master/'
11+
let githubUrl = ''
12+
$: {
13+
const path = $page.path.replace('/docs/', '')
14+
if (path.startsWith('library/'))
15+
githubUrl = githubPrefix + 'src/' + path.replace(/-/gu, '_') + '.lua'
16+
else githubUrl = githubPrefix + 'docs/' + path + '.md'
17+
}
618
</script>
719

820
<div class="flex md:space-x-12 wrapper my-16 w-full">
921
<aside class="hidden md:block w-40 lg:w-64 flex-none pt-1">
1022
<TableOfContents currentItem="{$page.path}" items="{libraryPages}" size="large" />
1123
</aside>
12-
<div class="prose max-w-full mx-auto">
13-
<slot />
24+
<div>
25+
<div class="prose max-w-full mx-auto">
26+
<slot />
27+
</div>
28+
{#if githubUrl}
29+
<Spacer />
30+
<div class="flex justify-end">
31+
<Button variant="secondary" prefix="{Github}" href="{githubUrl}"
32+
>Edit page on GitHub</Button
33+
>
34+
</div>
35+
{/if}
1436
</div>
1537
</div>

src/lib/lib/library-pages.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1 @@
1-
import type { TocItems } from '@nick-mazuk/ui-svelte/src/components/table-of-contents'
2-
3-
export const libraryPages: TocItems = [
4-
{
5-
text: 'Getting Started',
6-
href: '/docs/getting-started',
7-
children: [
8-
{ text: 'Adding Scripts', href: '/docs/getting-started/adding-scripts' },
9-
{ text: 'Resources', href: '/docs/getting-started/resources' },
10-
{ text: 'Style Guide', href: '/docs/getting-started/style-guide' },
11-
],
12-
},
13-
{
14-
text: 'Library',
15-
href: '/docs/library',
16-
children: [
17-
{ text: 'Articulation', href: '/docs/library/articulation' },
18-
{ text: 'Configuration', href: '/docs/library/configuration' },
19-
{ text: 'Enigma String', href: '/docs/library/enigma-string' },
20-
{ text: 'Expression', href: '/docs/library/expression' },
21-
{ text: 'General Library', href: '/docs/library/general-library' },
22-
{ text: 'Note Entry', href: '/docs/library/note-entry' },
23-
{ text: 'Transposition', href: '/docs/library/transposition' },
24-
],
25-
},
26-
]
1+
export const libraryPages: any[] = [{"text":"Getting Started","href":"/docs/getting-started","children":[{"text":"Adding Scripts","href":"/docs/getting-started/adding-scripts"},{"text":"Resources","href":"/docs/getting-started/resources"},{"text":"Style Guide","href":"/docs/getting-started/style-guide"}]},{"text":"Library","href":"/docs/library","children":[{"text":"Articulation","href":"/docs/library/articulation"},{"text":"Configuration","href":"/docs/library/configuration"},{"text":"Enigma String","href":"/docs/library/enigma-string"},{"text":"Expression","href":"/docs/library/expression"},{"text":"General Library","href":"/docs/library/general-library"},{"text":"Note Entry","href":"/docs/library/note-entry"},{"text":"Transposition","href":"/docs/library/transposition"}]}]

src/routes/docs/__layout.svelte

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
<script lang="ts">
22
import { page } from '$app/stores'
33
import TableOfContents from '@nick-mazuk/ui-svelte/src/components/table-of-contents/table-of-contents.svelte'
4+
import Button from '@nick-mazuk/ui-svelte/src/elements/button/button.svelte'
5+
import Github from '@nick-mazuk/ui-svelte/src/elements/icon/github.svelte'
6+
import Spacer from '@nick-mazuk/ui-svelte/src/utilities/spacer/spacer.svelte'
47
58
import { libraryPages } from '../../lib/lib/library-pages'
69
10+
const githubPrefix = 'https://github.com/Nick-Mazuk/jw-lua-scripts/blob/master/'
11+
let githubUrl = ''
12+
$: {
13+
const path = $page.path.replace('/docs/', '')
14+
if (path.startsWith('library/'))
15+
githubUrl = githubPrefix + 'src/' + path.replace(/-/gu, '_') + '.lua'
16+
else githubUrl = githubPrefix + 'docs/' + path + '.md'
17+
}
718
</script>
819

920
<div class="flex md:space-x-12 wrapper my-16 w-full">
1021
<aside class="hidden md:block w-40 lg:w-64 flex-none pt-1">
1122
<TableOfContents currentItem="{$page.path}" items="{libraryPages}" size="large" />
1223
</aside>
13-
<div class="prose max-w-full mx-auto">
14-
<slot />
24+
<div>
25+
<div class="prose max-w-full mx-auto">
26+
<slot />
27+
</div>
28+
{#if githubUrl}
29+
<Spacer />
30+
<div class="flex justify-end">
31+
<Button variant="secondary" prefix="{Github}" href="{githubUrl}"
32+
>Edit page on GitHub</Button
33+
>
34+
</div>
35+
{/if}
1536
</div>
1637
</div>

src/routes/docs/getting-started.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<script lang="ts">
42
import Markdown from '@nick-mazuk/ui-svelte/src/typography/markdown/markdown.svelte'
53

src/routes/docs/getting-started/adding-scripts.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<script lang="ts">
42
import Markdown from '@nick-mazuk/ui-svelte/src/typography/markdown/markdown.svelte'
53

src/routes/docs/getting-started/resources.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<script lang="ts">
42
import Markdown from '@nick-mazuk/ui-svelte/src/typography/markdown/markdown.svelte'
53

src/routes/docs/getting-started/style-guide.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<script lang="ts">
42
import Markdown from '@nick-mazuk/ui-svelte/src/typography/markdown/markdown.svelte'
53
@@ -27,7 +25,7 @@ any questions at all.
2725
2826
First off, and very importantly, I am a music composition major working as an engraver who’s only formal training in programming was three computer science courses in Python at Rice University via Coursera. Everything else has been learned through dissecting existing code and spending too many hours on stackoverflow.com. This document is intended to provide consistency in public JW Lua script development, it is not a reflection of best practices in the language of lua or a way to learn them. I am still learning, and will continue to learn.
2927
30-
Secondly, pobody’s nerfect and I am constantly refactoring my own code to make it consistent with the syntax explained in this document. This is a living document and will be changed and updated as we go. I am malleable on the stances taken here, however, I will always weigh the cost of refactoring time. What started off as an interest in saving time and a fun little project between Robert Puff and myself has grown quite a bit with interest in JW Lua. Though the bottom line is if your code works, your code works, however folks who write code generally do like consistency and these will be some explicit instructions for consistency sake when committing your code to the public JW Lua Git Repository set up by Nick Mazuk.
28+
Secondly, nobody’s perfect and I am constantly refactoring my own code to make it consistent with the syntax explained in this document. This is a living document and will be changed and updated as we go. I am malleable on the stances taken here, however, I will always weigh the cost of refactoring time. What started off as an interest in saving time and a fun little project between Robert Puff and myself has grown quite a bit with interest in JW Lua. Though the bottom line is if your code works, your code works, however folks who write code generally do like consistency and these will be some explicit instructions for consistency sake when committing your code to the public JW Lua Git Repository set up by Nick Mazuk.
3129
3230
Thirdly, for what it’s worth, I’m writing all of the code in Visual Studio Code with this Lua extension. I am using the Code Blocks chrome extension for this document with “gruvbox-dark” as the theme.
3331

src/routes/docs/library.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<script lang="ts">
42
import Markdown from '@nick-mazuk/ui-svelte/src/typography/markdown/markdown.svelte'
53

src/routes/docs/library/articulation.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<script lang="ts">
42
import Markdown from '@nick-mazuk/ui-svelte/src/typography/markdown/markdown.svelte'
53

0 commit comments

Comments
 (0)