@lapis-notes/lapis-plugin-docs 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +188 -2
- package/dist/docs/DocsBlockMarkdownEditor.svelte +37 -0
- package/dist/docs/DocsBlockMarkdownEditor.svelte.d.ts +13 -0
- package/dist/docs/DocsBlockRefPicker.svelte +75 -0
- package/dist/docs/DocsBlockRefPicker.svelte.d.ts +11 -0
- package/dist/docs/DocsBookEditor.svelte +141 -0
- package/dist/docs/DocsBookEditor.svelte.d.ts +10 -0
- package/dist/docs/DocsBookNavigation.svelte +838 -0
- package/dist/docs/DocsBookNavigation.svelte.d.ts +11 -0
- package/dist/docs/DocsBooksColumn.svelte +82 -0
- package/dist/docs/DocsBooksColumn.svelte.d.ts +10 -0
- package/dist/docs/DocsCardBackMatter.svelte +32 -0
- package/dist/docs/DocsCardBackMatter.svelte.d.ts +10 -0
- package/dist/docs/DocsCardBlockExtra.svelte +43 -0
- package/dist/docs/DocsCardBlockExtra.svelte.d.ts +9 -0
- package/dist/docs/DocsCardPreviewFlip.svelte +143 -0
- package/dist/docs/DocsCardPreviewFlip.svelte.d.ts +17 -0
- package/dist/docs/DocsCardPreviewStack.svelte +139 -0
- package/dist/docs/DocsCardPreviewStack.svelte.d.ts +13 -0
- package/dist/docs/DocsCardPrompt.svelte +33 -0
- package/dist/docs/DocsCardPrompt.svelte.d.ts +8 -0
- package/dist/docs/DocsCardReviewAnswer.svelte +45 -0
- package/dist/docs/DocsCardReviewAnswer.svelte.d.ts +8 -0
- package/dist/docs/DocsCardTagChips.svelte +19 -0
- package/dist/docs/DocsCardTagChips.svelte.d.ts +7 -0
- package/dist/docs/DocsCardsPanel.svelte +232 -0
- package/dist/docs/DocsCardsPanel.svelte.d.ts +17 -0
- package/dist/docs/DocsCardsReview.css +1050 -0
- package/dist/docs/DocsChapterFooter.svelte +248 -0
- package/dist/docs/DocsChapterFooter.svelte.d.ts +11 -0
- package/dist/docs/DocsChapterScrollRing.svelte +101 -0
- package/dist/docs/DocsChapterScrollRing.svelte.d.ts +6 -0
- package/dist/docs/DocsDisplayPanel.css +627 -0
- package/dist/docs/DocsDisplayPanel.svelte +78 -0
- package/dist/docs/DocsDisplayPanel.svelte.d.ts +16 -0
- package/dist/docs/DocsEditorPanel.css +325 -0
- package/dist/docs/DocsEditorPanel.svelte +570 -0
- package/dist/docs/DocsEditorPanel.svelte.d.ts +22 -0
- package/dist/docs/DocsFlipCard.svelte +68 -0
- package/dist/docs/DocsFlipCard.svelte.d.ts +8 -0
- package/dist/docs/DocsFolderDirectoryList.svelte +206 -0
- package/dist/docs/DocsFolderDirectoryList.svelte.d.ts +14 -0
- package/dist/docs/DocsFolderPanel.css +357 -0
- package/dist/docs/DocsFolderPanel.svelte +102 -0
- package/dist/docs/DocsFolderPanel.svelte.d.ts +17 -0
- package/dist/docs/DocsLinksPanel.css +61 -0
- package/dist/docs/DocsLinksPanel.svelte +55 -0
- package/dist/docs/DocsLinksPanel.svelte.d.ts +11 -0
- package/dist/docs/DocsMarkdownField.svelte +93 -0
- package/dist/docs/DocsMarkdownField.svelte.d.ts +11 -0
- package/dist/docs/DocsMarkdownPreview.svelte +278 -0
- package/dist/docs/DocsMarkdownPreview.svelte.d.ts +17 -0
- package/dist/docs/DocsReviewPanel.svelte +63 -0
- package/dist/docs/DocsReviewPanel.svelte.d.ts +11 -0
- package/dist/docs/DocsRichBlock.svelte +291 -0
- package/dist/docs/DocsRichBlock.svelte.d.ts +13 -0
- package/dist/docs/DocsRichDisplay.svelte +316 -0
- package/dist/docs/DocsRichDisplay.svelte.d.ts +14 -0
- package/dist/docs/DocsSlidesPreview.css +243 -0
- package/dist/docs/DocsSlidesPreview.svelte +206 -0
- package/dist/docs/DocsSlidesPreview.svelte.d.ts +10 -0
- package/dist/docs/DocsWorkspace.css +570 -0
- package/dist/docs/DocsWorkspace.svelte +831 -0
- package/dist/docs/DocsWorkspace.svelte.d.ts +48 -0
- package/dist/docs/DocsWorkspaceToolbar.svelte +211 -0
- package/dist/docs/DocsWorkspaceToolbar.svelte.d.ts +27 -0
- package/dist/docs/candidates/ChoiceMenu.svelte +114 -0
- package/dist/docs/candidates/ChoiceMenu.svelte.d.ts +10 -0
- package/dist/docs/candidates/FlipCardDeck.svelte +817 -0
- package/dist/docs/candidates/FlipCardDeck.svelte.d.ts +37 -0
- package/dist/docs/candidates/MarkdownFloatingToc.svelte +313 -0
- package/dist/docs/candidates/MarkdownFloatingToc.svelte.d.ts +14 -0
- package/dist/docs/candidates/SearchableChoicePicker.css +161 -0
- package/dist/docs/candidates/SearchableChoicePicker.svelte +208 -0
- package/dist/docs/candidates/SearchableChoicePicker.svelte.d.ts +19 -0
- package/dist/docs/candidates/StructuredTable.svelte +98 -0
- package/dist/docs/candidates/StructuredTable.svelte.d.ts +8 -0
- package/dist/docs/candidates/StructuredTableEditor.svelte +374 -0
- package/dist/docs/candidates/StructuredTableEditor.svelte.d.ts +12 -0
- package/dist/docs/candidates/TagEditor.svelte +31 -0
- package/dist/docs/candidates/TagEditor.svelte.d.ts +14 -0
- package/dist/docs/candidates/WorkspaceHistoryControls.svelte +112 -0
- package/dist/docs/candidates/WorkspaceHistoryControls.svelte.d.ts +8 -0
- package/dist/docs/candidates/markdown-floating-toc.css +151 -0
- package/dist/docs/candidates/markdown-floating-toc.d.ts +1 -0
- package/dist/docs/candidates/markdown-floating-toc.js +1 -0
- package/dist/docs/docs-anki-import.d.ts +34 -0
- package/dist/docs/docs-anki-import.js +516 -0
- package/dist/docs/docs-book-view-model.d.ts +9 -0
- package/dist/docs/docs-book-view-model.js +71 -0
- package/dist/docs/docs-card-answer-markdown.d.ts +1 -0
- package/dist/docs/docs-card-answer-markdown.js +63 -0
- package/dist/docs/docs-card-display.d.ts +10 -0
- package/dist/docs/docs-card-display.js +18 -0
- package/dist/docs/docs-display-focus.d.ts +7 -0
- package/dist/docs/docs-display-focus.js +42 -0
- package/dist/docs/docs-document-surface.d.ts +7 -0
- package/dist/docs/docs-document-surface.js +25 -0
- package/dist/docs/docs-folder-directory.d.ts +21 -0
- package/dist/docs/docs-folder-directory.js +56 -0
- package/dist/docs/docs-link-mode.d.ts +16 -0
- package/dist/docs/docs-link-mode.js +94 -0
- package/dist/docs/docs-workspace-helpers.d.ts +25 -0
- package/dist/docs/docs-workspace-helpers.js +195 -0
- package/dist/docs/docs.tokens.css +13 -0
- package/dist/docs/import-anki-package.d.ts +10 -0
- package/dist/docs/import-anki-package.js +30 -0
- package/dist/docs/lapis-markdown-extensions.d.ts +9 -0
- package/dist/docs/lapis-markdown-extensions.js +128 -0
- package/dist/docs/pin-reading-chrome.d.ts +4 -0
- package/dist/docs/pin-reading-chrome.js +32 -0
- package/dist/docs/sidebar/DocsFoldersSidebar.svelte +134 -0
- package/dist/docs/sidebar/DocsFoldersSidebar.svelte.d.ts +15 -0
- package/dist/docs/sidebar/DocsLinksSidebar.svelte +105 -0
- package/dist/docs/sidebar/DocsLinksSidebar.svelte.d.ts +11 -0
- package/dist/docs/sidebar/DocsSidebar.css +346 -0
- package/dist/docs/sidebar/DocsSidebar.svelte +430 -0
- package/dist/docs/sidebar/DocsSidebar.svelte.d.ts +18 -0
- package/dist/docs/sidebar/DocsSidebarHost.svelte +139 -0
- package/dist/docs/sidebar/DocsSidebarHost.svelte.d.ts +12 -0
- package/dist/docs/sidebar/DocsTagsSidebar.svelte +176 -0
- package/dist/docs/sidebar/DocsTagsSidebar.svelte.d.ts +12 -0
- package/dist/docs/sidebar/docs-book-note-tree.d.ts +23 -0
- package/dist/docs/sidebar/docs-book-note-tree.js +88 -0
- package/dist/docs/sidebar/docs-note-sort.d.ts +26 -0
- package/dist/docs/sidebar/docs-note-sort.js +54 -0
- package/dist/docs/sidebar/docs-sidebar-filters.d.ts +17 -0
- package/dist/docs/sidebar/docs-sidebar-filters.js +74 -0
- package/dist/docs/sidebar/docs-sidebar-ui-storage.d.ts +24 -0
- package/dist/docs/sidebar/docs-sidebar-ui-storage.js +87 -0
- package/dist/docs/sidebar/docs-source-folder-tree.d.ts +16 -0
- package/dist/docs/sidebar/docs-source-folder-tree.js +143 -0
- package/dist/docs/sidebar/docs-tag-tree.d.ts +17 -0
- package/dist/docs/sidebar/docs-tag-tree.js +84 -0
- package/dist/docs-cards-view.d.ts +18 -0
- package/dist/docs-cards-view.js +52 -0
- package/dist/docs-document-view.d.ts +24 -0
- package/dist/docs-document-view.js +127 -0
- package/dist/docs-document-workspace.svelte +215 -0
- package/dist/docs-document-workspace.svelte.d.ts +16 -0
- package/dist/docs-index.d.ts +5 -0
- package/dist/docs-index.js +49 -0
- package/dist/docs-path.d.ts +6 -0
- package/dist/docs-path.js +10 -0
- package/dist/docs-plugin.d.ts +21 -0
- package/dist/docs-plugin.js +140 -0
- package/dist/docs-repository.d.ts +15 -0
- package/dist/docs-repository.js +75 -0
- package/dist/docs-review-view.d.ts +18 -0
- package/dist/docs-review-view.js +52 -0
- package/dist/docs-settings-tab.d.ts +8 -0
- package/dist/docs-settings-tab.js +25 -0
- package/dist/docs-settings.d.ts +17 -0
- package/dist/docs-settings.js +38 -0
- package/dist/docs-view.d.ts +22 -0
- package/dist/docs-view.js +51 -0
- package/dist/docs-workspace.svelte +394 -0
- package/dist/docs-workspace.svelte.d.ts +15 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/model/book.d.ts +6 -0
- package/dist/model/book.js +101 -0
- package/dist/model/coding-runtime.d.ts +4 -0
- package/dist/model/coding-runtime.js +9 -0
- package/dist/model/docs-card-context.d.ts +32 -0
- package/dist/model/docs-card-context.js +89 -0
- package/dist/model/docs-card-preview-stack-motion.d.ts +51 -0
- package/dist/model/docs-card-preview-stack-motion.js +94 -0
- package/dist/model/docs-media-context.d.ts +9 -0
- package/dist/model/docs-media-context.js +18 -0
- package/dist/model/docs-note-list.d.ts +8 -0
- package/dist/model/docs-note-list.js +25 -0
- package/dist/model/docs-relative-media.d.ts +30 -0
- package/dist/model/docs-relative-media.js +116 -0
- package/dist/model/docs-review-constants.d.ts +4 -0
- package/dist/model/docs-review-constants.js +13 -0
- package/dist/model/fsrs.d.ts +14 -0
- package/dist/model/fsrs.js +153 -0
- package/dist/model/graph.d.ts +12 -0
- package/dist/model/graph.js +169 -0
- package/dist/model/index.d.ts +14 -0
- package/dist/model/index.js +14 -0
- package/dist/model/markdown-normalize.d.ts +11 -0
- package/dist/model/markdown-normalize.js +755 -0
- package/dist/model/markdown.d.ts +167 -0
- package/dist/model/markdown.js +365 -0
- package/dist/model/sample.d.ts +7 -0
- package/dist/model/sample.js +524 -0
- package/dist/model/types.d.ts +328 -0
- package/dist/model/types.js +1 -0
- package/dist/model/workspace.d.ts +6 -0
- package/dist/model/workspace.js +81 -0
- package/dist/storybook.css +52 -0
- package/dist/styles.css +1 -0
- package/manifest.json +11 -0
- package/package.json +147 -4
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type DocsNote, type DocsRevisionBlock } from "./types";
|
|
2
|
+
export { assertDocsId, createDocsNote, createDocsCodingExercise, isValidDocsId, normalizeDocsBlock, normalizeDocsCodingExercise, normalizeDocsCard, parseDocsNoteMarkdownFile, slugifyDocsId, } from "./markdown-normalize";
|
|
3
|
+
export declare function docsNoteToFrontmatter(note: DocsNote): Partial<{
|
|
4
|
+
schemaVersion: string;
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
docType: import("./types").DocsDocType;
|
|
8
|
+
summary: string;
|
|
9
|
+
learningGoal: string;
|
|
10
|
+
aliases: string[];
|
|
11
|
+
tags: string[];
|
|
12
|
+
book: {
|
|
13
|
+
chapters: {
|
|
14
|
+
noteId: string;
|
|
15
|
+
}[];
|
|
16
|
+
} | undefined;
|
|
17
|
+
bookId: string | undefined;
|
|
18
|
+
completedAt: string | undefined;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
blocks: (Partial<{
|
|
22
|
+
id: string;
|
|
23
|
+
type: "concept";
|
|
24
|
+
title: string | undefined;
|
|
25
|
+
summary: string;
|
|
26
|
+
keyPoints: string[];
|
|
27
|
+
details: string;
|
|
28
|
+
}> | Partial<{
|
|
29
|
+
id: string;
|
|
30
|
+
type: "procedure";
|
|
31
|
+
title: string | undefined;
|
|
32
|
+
steps: string[];
|
|
33
|
+
notes: string;
|
|
34
|
+
}> | Partial<{
|
|
35
|
+
id: string;
|
|
36
|
+
type: "prompt";
|
|
37
|
+
title: string | undefined;
|
|
38
|
+
problem: string;
|
|
39
|
+
requirements: string[];
|
|
40
|
+
approach: string;
|
|
41
|
+
traps: string[];
|
|
42
|
+
tests: string[];
|
|
43
|
+
answer: string;
|
|
44
|
+
}> | Partial<{
|
|
45
|
+
id: string;
|
|
46
|
+
type: "code";
|
|
47
|
+
title: string | undefined;
|
|
48
|
+
language: string;
|
|
49
|
+
code: string;
|
|
50
|
+
caption: string;
|
|
51
|
+
}> | Partial<{
|
|
52
|
+
id: string;
|
|
53
|
+
type: "table";
|
|
54
|
+
title: string | undefined;
|
|
55
|
+
columns: string[];
|
|
56
|
+
rows: string[][];
|
|
57
|
+
}> | Partial<{
|
|
58
|
+
id: string;
|
|
59
|
+
type: "story";
|
|
60
|
+
title: string | undefined;
|
|
61
|
+
useFor: string[];
|
|
62
|
+
situation: string;
|
|
63
|
+
task: string;
|
|
64
|
+
action: string;
|
|
65
|
+
result: string;
|
|
66
|
+
metrics: string[];
|
|
67
|
+
}> | Partial<{
|
|
68
|
+
id: string;
|
|
69
|
+
type: "resources";
|
|
70
|
+
title: string | undefined;
|
|
71
|
+
items: Partial<{
|
|
72
|
+
title: string;
|
|
73
|
+
url: string;
|
|
74
|
+
kind: string;
|
|
75
|
+
notes: string;
|
|
76
|
+
}>[];
|
|
77
|
+
}> | Partial<{
|
|
78
|
+
id: string;
|
|
79
|
+
type: string;
|
|
80
|
+
title: string | undefined;
|
|
81
|
+
body: string;
|
|
82
|
+
}>)[];
|
|
83
|
+
cards: Partial<{
|
|
84
|
+
exercise: Partial<{
|
|
85
|
+
id: string;
|
|
86
|
+
difficulty: import("./types").DocsCodingDifficulty;
|
|
87
|
+
description: string;
|
|
88
|
+
constraints: string[];
|
|
89
|
+
signature: {
|
|
90
|
+
className: string;
|
|
91
|
+
methodName: string;
|
|
92
|
+
parameters: {
|
|
93
|
+
name: string;
|
|
94
|
+
type: import("./types").DocsCodingValueType;
|
|
95
|
+
}[];
|
|
96
|
+
returnType: import("./types").DocsCodingValueType;
|
|
97
|
+
};
|
|
98
|
+
languages: {
|
|
99
|
+
language: import("./types").DocsCodingLanguage;
|
|
100
|
+
version: string;
|
|
101
|
+
fileName: string;
|
|
102
|
+
starterCode: string;
|
|
103
|
+
}[];
|
|
104
|
+
examples: Partial<{
|
|
105
|
+
id: string;
|
|
106
|
+
title: string | undefined;
|
|
107
|
+
arguments: import("./types").DocsCodingLiteral[];
|
|
108
|
+
expected: import("./types").DocsCodingLiteral;
|
|
109
|
+
explanation: string | undefined;
|
|
110
|
+
}>[];
|
|
111
|
+
hints: {
|
|
112
|
+
id: string;
|
|
113
|
+
title: string;
|
|
114
|
+
body: string;
|
|
115
|
+
}[];
|
|
116
|
+
solutions: Partial<{
|
|
117
|
+
language: import("./types").DocsCodingLanguage;
|
|
118
|
+
explanation: string | undefined;
|
|
119
|
+
code: string;
|
|
120
|
+
}>[];
|
|
121
|
+
}>;
|
|
122
|
+
id: string;
|
|
123
|
+
type: import("./types").DocsCardType;
|
|
124
|
+
status: import("./types").DocsCardStatus;
|
|
125
|
+
prompt: string;
|
|
126
|
+
answer: string;
|
|
127
|
+
tags: string[];
|
|
128
|
+
blockRefs: string[];
|
|
129
|
+
} | {
|
|
130
|
+
fsrs: Partial<{
|
|
131
|
+
due: string;
|
|
132
|
+
stability: number;
|
|
133
|
+
difficulty: number;
|
|
134
|
+
elapsedDays: number;
|
|
135
|
+
scheduledDays: number;
|
|
136
|
+
learningSteps: number;
|
|
137
|
+
reps: number;
|
|
138
|
+
lapses: number;
|
|
139
|
+
state: import("./types").DocsFsrsStateName;
|
|
140
|
+
lastReview: string | undefined;
|
|
141
|
+
}> | undefined;
|
|
142
|
+
reviews: Partial<{
|
|
143
|
+
id: string;
|
|
144
|
+
rating: import("./types").DocsReviewRating;
|
|
145
|
+
reviewedAt: string;
|
|
146
|
+
state: import("./types").DocsFsrsStateName;
|
|
147
|
+
due: string;
|
|
148
|
+
stability: number;
|
|
149
|
+
difficulty: number;
|
|
150
|
+
elapsedDays: number;
|
|
151
|
+
scheduledDays: number;
|
|
152
|
+
learningSteps: number;
|
|
153
|
+
}>[];
|
|
154
|
+
id: string;
|
|
155
|
+
type: import("./types").DocsCardType;
|
|
156
|
+
status: import("./types").DocsCardStatus;
|
|
157
|
+
prompt: string;
|
|
158
|
+
answer: string;
|
|
159
|
+
tags: string[];
|
|
160
|
+
blockRefs: string[];
|
|
161
|
+
}>[];
|
|
162
|
+
}>;
|
|
163
|
+
export declare function docsNoteToMarkdown(note: DocsNote): string;
|
|
164
|
+
export declare function renderDocsBlockMarkdown(block: DocsRevisionBlock, headingLevel?: number): string;
|
|
165
|
+
export declare function renderDocsNoteMarkdown(note: DocsNote, options?: {
|
|
166
|
+
mode?: "document" | "slides";
|
|
167
|
+
}): string;
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import YAML from "yaml";
|
|
2
|
+
import { DOCS_NOTE_SCHEMA_VERSION, } from "./types";
|
|
3
|
+
import { assertDocsId, compactObject } from "./markdown-normalize";
|
|
4
|
+
export { assertDocsId, createDocsNote, createDocsCodingExercise, isValidDocsId, normalizeDocsBlock, normalizeDocsCodingExercise, normalizeDocsCard, parseDocsNoteMarkdownFile, slugifyDocsId, } from "./markdown-normalize";
|
|
5
|
+
function serializeFsrs(fsrsState) {
|
|
6
|
+
if (!fsrsState)
|
|
7
|
+
return undefined;
|
|
8
|
+
return compactObject({
|
|
9
|
+
due: fsrsState.due,
|
|
10
|
+
stability: fsrsState.stability,
|
|
11
|
+
difficulty: fsrsState.difficulty,
|
|
12
|
+
elapsedDays: fsrsState.elapsedDays,
|
|
13
|
+
scheduledDays: fsrsState.scheduledDays,
|
|
14
|
+
learningSteps: fsrsState.learningSteps,
|
|
15
|
+
reps: fsrsState.reps,
|
|
16
|
+
lapses: fsrsState.lapses,
|
|
17
|
+
state: fsrsState.state,
|
|
18
|
+
lastReview: fsrsState.lastReview,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function serializeReviews(reviews) {
|
|
22
|
+
return reviews.map((review) => compactObject({
|
|
23
|
+
id: review.id,
|
|
24
|
+
rating: review.rating,
|
|
25
|
+
reviewedAt: review.reviewedAt,
|
|
26
|
+
state: review.state,
|
|
27
|
+
due: review.due,
|
|
28
|
+
stability: review.stability,
|
|
29
|
+
difficulty: review.difficulty,
|
|
30
|
+
elapsedDays: review.elapsedDays,
|
|
31
|
+
scheduledDays: review.scheduledDays,
|
|
32
|
+
learningSteps: review.learningSteps,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
function serializeBook(book) {
|
|
36
|
+
if (!book)
|
|
37
|
+
return undefined;
|
|
38
|
+
return {
|
|
39
|
+
chapters: book.chapters.map((chapter) => ({
|
|
40
|
+
noteId: assertDocsId(chapter.noteId),
|
|
41
|
+
})),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function serializeBlock(block) {
|
|
45
|
+
switch (block.type) {
|
|
46
|
+
case "concept":
|
|
47
|
+
return compactObject({
|
|
48
|
+
id: block.id,
|
|
49
|
+
type: block.type,
|
|
50
|
+
title: block.title,
|
|
51
|
+
summary: block.summary,
|
|
52
|
+
keyPoints: block.keyPoints,
|
|
53
|
+
details: block.details,
|
|
54
|
+
});
|
|
55
|
+
case "procedure":
|
|
56
|
+
return compactObject({
|
|
57
|
+
id: block.id,
|
|
58
|
+
type: block.type,
|
|
59
|
+
title: block.title,
|
|
60
|
+
steps: block.steps,
|
|
61
|
+
notes: block.notes,
|
|
62
|
+
});
|
|
63
|
+
case "prompt":
|
|
64
|
+
return compactObject({
|
|
65
|
+
id: block.id,
|
|
66
|
+
type: block.type,
|
|
67
|
+
title: block.title,
|
|
68
|
+
problem: block.problem,
|
|
69
|
+
requirements: block.requirements,
|
|
70
|
+
approach: block.approach,
|
|
71
|
+
traps: block.traps,
|
|
72
|
+
tests: block.tests,
|
|
73
|
+
answer: block.answer,
|
|
74
|
+
});
|
|
75
|
+
case "code":
|
|
76
|
+
return compactObject({
|
|
77
|
+
id: block.id,
|
|
78
|
+
type: block.type,
|
|
79
|
+
title: block.title,
|
|
80
|
+
language: block.language,
|
|
81
|
+
code: block.code,
|
|
82
|
+
caption: block.caption,
|
|
83
|
+
});
|
|
84
|
+
case "table":
|
|
85
|
+
return compactObject({
|
|
86
|
+
id: block.id,
|
|
87
|
+
type: block.type,
|
|
88
|
+
title: block.title,
|
|
89
|
+
columns: block.columns,
|
|
90
|
+
rows: block.rows,
|
|
91
|
+
});
|
|
92
|
+
case "callout":
|
|
93
|
+
return compactObject({
|
|
94
|
+
id: block.id,
|
|
95
|
+
type: block.type,
|
|
96
|
+
title: block.title,
|
|
97
|
+
tone: block.tone,
|
|
98
|
+
body: block.body,
|
|
99
|
+
});
|
|
100
|
+
case "story":
|
|
101
|
+
return compactObject({
|
|
102
|
+
id: block.id,
|
|
103
|
+
type: block.type,
|
|
104
|
+
title: block.title,
|
|
105
|
+
useFor: block.useFor,
|
|
106
|
+
situation: block.situation,
|
|
107
|
+
task: block.task,
|
|
108
|
+
action: block.action,
|
|
109
|
+
result: block.result,
|
|
110
|
+
metrics: block.metrics,
|
|
111
|
+
});
|
|
112
|
+
case "resources":
|
|
113
|
+
return compactObject({
|
|
114
|
+
id: block.id,
|
|
115
|
+
type: block.type,
|
|
116
|
+
title: block.title,
|
|
117
|
+
items: block.items.map((item) => compactObject({
|
|
118
|
+
title: item.title,
|
|
119
|
+
url: item.url,
|
|
120
|
+
kind: item.kind,
|
|
121
|
+
notes: item.notes,
|
|
122
|
+
})),
|
|
123
|
+
});
|
|
124
|
+
case "markdown":
|
|
125
|
+
return compactObject({
|
|
126
|
+
id: block.id,
|
|
127
|
+
type: "markdown",
|
|
128
|
+
title: block.title,
|
|
129
|
+
body: block.body,
|
|
130
|
+
});
|
|
131
|
+
case "text":
|
|
132
|
+
default:
|
|
133
|
+
return compactObject({
|
|
134
|
+
id: block.id,
|
|
135
|
+
type: "text",
|
|
136
|
+
title: block.title,
|
|
137
|
+
body: block.body,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function serializeCard(card) {
|
|
142
|
+
return compactObject({
|
|
143
|
+
id: card.id,
|
|
144
|
+
type: card.type,
|
|
145
|
+
status: card.status,
|
|
146
|
+
prompt: card.prompt,
|
|
147
|
+
answer: card.answer,
|
|
148
|
+
tags: card.tags,
|
|
149
|
+
blockRefs: card.blockRefs,
|
|
150
|
+
...(card.type === "coding" && card.exercise
|
|
151
|
+
? { exercise: serializeCodingExercise(card.exercise) }
|
|
152
|
+
: {
|
|
153
|
+
fsrs: serializeFsrs(card.fsrs),
|
|
154
|
+
reviews: serializeReviews(card.reviews),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function serializeCodingExercise(exercise) {
|
|
159
|
+
return compactObject({
|
|
160
|
+
id: assertDocsId(exercise.id),
|
|
161
|
+
difficulty: exercise.difficulty,
|
|
162
|
+
description: exercise.description,
|
|
163
|
+
constraints: exercise.constraints,
|
|
164
|
+
signature: {
|
|
165
|
+
className: exercise.signature.className,
|
|
166
|
+
methodName: exercise.signature.methodName,
|
|
167
|
+
parameters: exercise.signature.parameters.map((parameter) => ({
|
|
168
|
+
name: parameter.name,
|
|
169
|
+
type: parameter.type,
|
|
170
|
+
})),
|
|
171
|
+
returnType: exercise.signature.returnType,
|
|
172
|
+
},
|
|
173
|
+
languages: exercise.languages.map((language) => ({
|
|
174
|
+
language: language.language,
|
|
175
|
+
version: language.version,
|
|
176
|
+
fileName: language.fileName,
|
|
177
|
+
starterCode: language.starterCode,
|
|
178
|
+
})),
|
|
179
|
+
examples: exercise.examples.map((example) => compactObject({
|
|
180
|
+
id: assertDocsId(example.id),
|
|
181
|
+
title: example.title,
|
|
182
|
+
arguments: example.arguments,
|
|
183
|
+
expected: example.expected,
|
|
184
|
+
explanation: example.explanation,
|
|
185
|
+
})),
|
|
186
|
+
hints: (exercise.hints ?? []).map((hint) => ({
|
|
187
|
+
id: assertDocsId(hint.id),
|
|
188
|
+
title: hint.title,
|
|
189
|
+
body: hint.body,
|
|
190
|
+
})),
|
|
191
|
+
solutions: (exercise.solutions ?? []).map((solution) => compactObject({
|
|
192
|
+
language: solution.language,
|
|
193
|
+
explanation: solution.explanation,
|
|
194
|
+
code: solution.code,
|
|
195
|
+
})),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
export function docsNoteToFrontmatter(note) {
|
|
199
|
+
return compactObject({
|
|
200
|
+
schemaVersion: DOCS_NOTE_SCHEMA_VERSION,
|
|
201
|
+
id: assertDocsId(note.id),
|
|
202
|
+
title: note.title,
|
|
203
|
+
docType: note.docType,
|
|
204
|
+
summary: note.summary,
|
|
205
|
+
learningGoal: note.learningGoal,
|
|
206
|
+
aliases: note.aliases,
|
|
207
|
+
tags: note.tags,
|
|
208
|
+
book: serializeBook(note.book),
|
|
209
|
+
bookId: note.bookId,
|
|
210
|
+
completedAt: note.completedAt,
|
|
211
|
+
createdAt: note.createdAt,
|
|
212
|
+
updatedAt: note.updatedAt,
|
|
213
|
+
blocks: note.blocks.map(serializeBlock),
|
|
214
|
+
cards: note.cards.map(serializeCard),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
export function docsNoteToMarkdown(note) {
|
|
218
|
+
const frontmatter = docsNoteToFrontmatter(note);
|
|
219
|
+
const body = note.body.trim();
|
|
220
|
+
return `---\n${YAML.stringify(frontmatter, { lineWidth: 100 }).trimEnd()}\n---\n${body ? `\n${body}\n` : ""}`;
|
|
221
|
+
}
|
|
222
|
+
function markdownHeading(level, title) {
|
|
223
|
+
return `${"#".repeat(Math.max(1, Math.min(level, 6)))} ${title}`;
|
|
224
|
+
}
|
|
225
|
+
function compactMarkdown(parts) {
|
|
226
|
+
return parts
|
|
227
|
+
.map((part) => part?.trim())
|
|
228
|
+
.filter((part) => Boolean(part))
|
|
229
|
+
.join("\n\n");
|
|
230
|
+
}
|
|
231
|
+
function markdownList(items, ordered = false) {
|
|
232
|
+
return items
|
|
233
|
+
.map((item, index) => `${ordered ? `${index + 1}.` : "-"} ${item}`)
|
|
234
|
+
.join("\n");
|
|
235
|
+
}
|
|
236
|
+
function markdownTableCell(value) {
|
|
237
|
+
return value.replaceAll("|", "\\|").replace(/\s+/g, " ").trim();
|
|
238
|
+
}
|
|
239
|
+
function markdownTable(columns, rows) {
|
|
240
|
+
if (!columns.length)
|
|
241
|
+
return "";
|
|
242
|
+
const header = `| ${columns.map(markdownTableCell).join(" | ")} |`;
|
|
243
|
+
const separator = `| ${columns.map(() => "---").join(" | ")} |`;
|
|
244
|
+
const body = rows
|
|
245
|
+
.map((row) => {
|
|
246
|
+
const cells = columns.map((_, index) => markdownTableCell(row[index] ?? ""));
|
|
247
|
+
return `| ${cells.join(" | ")} |`;
|
|
248
|
+
})
|
|
249
|
+
.join("\n");
|
|
250
|
+
return [header, separator, body].filter(Boolean).join("\n");
|
|
251
|
+
}
|
|
252
|
+
function blockTitle(block) {
|
|
253
|
+
return block.title?.trim() || block.type.replace("-", " ");
|
|
254
|
+
}
|
|
255
|
+
function renderCalloutBody(value) {
|
|
256
|
+
return value
|
|
257
|
+
.split(/\r?\n/)
|
|
258
|
+
.map((line) => `> ${line}`)
|
|
259
|
+
.join("\n");
|
|
260
|
+
}
|
|
261
|
+
export function renderDocsBlockMarkdown(block, headingLevel = 2) {
|
|
262
|
+
const title = markdownHeading(headingLevel, blockTitle(block));
|
|
263
|
+
switch (block.type) {
|
|
264
|
+
case "concept":
|
|
265
|
+
return compactMarkdown([
|
|
266
|
+
title,
|
|
267
|
+
block.summary,
|
|
268
|
+
block.keyPoints.length ? markdownList(block.keyPoints) : undefined,
|
|
269
|
+
block.details,
|
|
270
|
+
]);
|
|
271
|
+
case "procedure":
|
|
272
|
+
return compactMarkdown([
|
|
273
|
+
title,
|
|
274
|
+
block.steps.length ? markdownList(block.steps, true) : undefined,
|
|
275
|
+
block.notes,
|
|
276
|
+
]);
|
|
277
|
+
case "prompt":
|
|
278
|
+
return compactMarkdown([
|
|
279
|
+
title,
|
|
280
|
+
block.problem,
|
|
281
|
+
block.requirements.length
|
|
282
|
+
? `${markdownHeading(headingLevel + 1, "Requirements")}\n\n${markdownList(block.requirements)}`
|
|
283
|
+
: undefined,
|
|
284
|
+
block.approach
|
|
285
|
+
? `${markdownHeading(headingLevel + 1, "Approach")}\n\n${block.approach}`
|
|
286
|
+
: undefined,
|
|
287
|
+
block.traps.length
|
|
288
|
+
? `${markdownHeading(headingLevel + 1, "Traps")}\n\n${markdownList(block.traps)}`
|
|
289
|
+
: undefined,
|
|
290
|
+
block.tests.length
|
|
291
|
+
? `${markdownHeading(headingLevel + 1, "Good tests")}\n\n${markdownList(block.tests)}`
|
|
292
|
+
: undefined,
|
|
293
|
+
block.answer
|
|
294
|
+
? `${markdownHeading(headingLevel + 1, "Answer")}\n\n${block.answer}`
|
|
295
|
+
: undefined,
|
|
296
|
+
]);
|
|
297
|
+
case "code":
|
|
298
|
+
return compactMarkdown([
|
|
299
|
+
title,
|
|
300
|
+
block.caption,
|
|
301
|
+
`\`\`\`${block.language}\n${block.code}\n\`\`\``,
|
|
302
|
+
]);
|
|
303
|
+
case "table":
|
|
304
|
+
return compactMarkdown([title, markdownTable(block.columns, block.rows)]);
|
|
305
|
+
case "callout":
|
|
306
|
+
return compactMarkdown([
|
|
307
|
+
`> [!${block.tone.toUpperCase()}]${block.title ? ` ${block.title}` : ""}`,
|
|
308
|
+
renderCalloutBody(block.body),
|
|
309
|
+
]);
|
|
310
|
+
case "story":
|
|
311
|
+
return compactMarkdown([
|
|
312
|
+
title,
|
|
313
|
+
block.useFor.length
|
|
314
|
+
? `**Use for:** ${block.useFor.join(", ")}`
|
|
315
|
+
: undefined,
|
|
316
|
+
block.situation ? `**Situation:** ${block.situation}` : undefined,
|
|
317
|
+
block.task ? `**Task:** ${block.task}` : undefined,
|
|
318
|
+
block.action ? `**Action:** ${block.action}` : undefined,
|
|
319
|
+
block.result ? `**Result:** ${block.result}` : undefined,
|
|
320
|
+
block.metrics.length
|
|
321
|
+
? `${markdownHeading(headingLevel + 1, "Metrics")}\n\n${markdownList(block.metrics)}`
|
|
322
|
+
: undefined,
|
|
323
|
+
]);
|
|
324
|
+
case "resources":
|
|
325
|
+
return compactMarkdown([
|
|
326
|
+
title,
|
|
327
|
+
block.items
|
|
328
|
+
.map((item) => {
|
|
329
|
+
const label = item.url
|
|
330
|
+
? `[${item.title}](${item.url})`
|
|
331
|
+
: item.title;
|
|
332
|
+
const meta = [item.kind, item.notes].filter(Boolean).join(" - ");
|
|
333
|
+
return `- ${label}${meta ? ` - ${meta}` : ""}`;
|
|
334
|
+
})
|
|
335
|
+
.join("\n"),
|
|
336
|
+
]);
|
|
337
|
+
case "markdown":
|
|
338
|
+
return compactMarkdown([block.title ? title : undefined, block.body]);
|
|
339
|
+
case "text":
|
|
340
|
+
default:
|
|
341
|
+
return compactMarkdown([block.title ? title : undefined, block.body]);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
export function renderDocsNoteMarkdown(note, options = {}) {
|
|
345
|
+
const mode = options.mode ?? "document";
|
|
346
|
+
const intro = compactMarkdown([
|
|
347
|
+
markdownHeading(1, note.title),
|
|
348
|
+
note.summary,
|
|
349
|
+
note.learningGoal ? `**Learning goal:** ${note.learningGoal}` : undefined,
|
|
350
|
+
]);
|
|
351
|
+
const renderedBlocks = note.blocks.map((block) => renderDocsBlockMarkdown(block, mode === "slides" ? 2 : 2));
|
|
352
|
+
const body = note.body && note.blocks.length
|
|
353
|
+
? compactMarkdown([markdownHeading(2, "Additional notes"), note.body])
|
|
354
|
+
: note.body;
|
|
355
|
+
if (mode === "slides") {
|
|
356
|
+
return compactMarkdown([
|
|
357
|
+
`---\nmarp: true\ntitle: ${JSON.stringify(note.title)}\n---`,
|
|
358
|
+
[intro, ...renderedBlocks, body]
|
|
359
|
+
.map((part) => part.trim())
|
|
360
|
+
.filter(Boolean)
|
|
361
|
+
.join("\n\n---\n\n"),
|
|
362
|
+
]);
|
|
363
|
+
}
|
|
364
|
+
return compactMarkdown([intro, ...renderedBlocks, body]);
|
|
365
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DocsNote } from "./types";
|
|
2
|
+
export declare const SAMPLE_DOCS_BOOK_FOLDER = "sample-docs";
|
|
3
|
+
export declare const SAMPLE_DOCS_BOOK_INDEX_ID = "sample-docs-index";
|
|
4
|
+
export declare const SAMPLE_DOCS_BOOK_TAG = "books/sample-docs";
|
|
5
|
+
export declare const SAMPLE_DOCS_NOTE_IDS: readonly ["sample-docs-schema-harness", "sample-docs-coding-drill", "sample-docs-system-design", "sample-docs-story-bank", "sample-docs-freeform", "sample-docs-index"];
|
|
6
|
+
export declare const SAMPLE_DOCS_CHAPTER_IDS: readonly ["sample-docs-schema-harness", "sample-docs-coding-drill", "sample-docs-system-design", "sample-docs-story-bank", "sample-docs-freeform"];
|
|
7
|
+
export declare function sampleDocsNotes(): DocsNote[];
|