Skip to content

Commit 1060804

Browse files
committed
Enhance documentation with GitHub callouts support and refine tab conversion
Signed-off-by: Pete Cheslock <[email protected]>
1 parent b468c4a commit 1060804

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,14 @@ When writing documentation in source repositories (like llm-d/llm-d) that will b
171171
172172
<!-- TABS:START -->
173173
<!-- TAB:GKE (H200):default -->
174-
```bash
175174
kubectl apply -k ./manifests/modelserver/gke -n ${NAMESPACE}
176-
```
177175
178176
<!-- TAB:GKE (B200) -->
179-
```bash
180177
kubectl apply -k ./manifests/modelserver/gke-a4 -n ${NAMESPACE}
181-
```
182178
183179
<!-- TAB:CoreWeave -->
184-
```bash
185180
kubectl apply -k ./manifests/modelserver/coreweave -n ${NAMESPACE}
186-
```
181+
187182
<!-- TABS:END -->
188183
```
189184

@@ -198,6 +193,32 @@ kubectl apply -k ./manifests/modelserver/coreweave -n ${NAMESPACE}
198193
**Result on Docusaurus:**
199194
The content will automatically be transformed with the proper Tabs imports and components, creating an interactive tabbed interface.
200195

196+
### GitHub Callouts Support
197+
198+
The transformation system also automatically converts GitHub-style callouts to Docusaurus admonitions:
199+
200+
```markdown
201+
> [!NOTE]
202+
> This is a note
203+
204+
> [!TIP]
205+
> This is a tip
206+
207+
> [!IMPORTANT]
208+
> This is important
209+
210+
> [!WARNING]
211+
> This is a warning
212+
213+
> [!CAUTION]
214+
> This is dangerous
215+
216+
> [!REQUIREMENTS]
217+
> These are requirements
218+
```
219+
220+
These will be automatically converted to the appropriate Docusaurus `:::note`, `:::tip`, `:::info`, `:::warning`, and `:::danger` admonitions during the build.
221+
201222
### Troubleshooting
202223

203224
| Problem | Solution |

remote-content/remote-sources/repo-transforms.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,22 @@ function convertTabsToDocusaurus(content) {
6767
const tabBlockRegex = /<!-- TABS:START -->\n([\s\S]*?)<!-- TABS:END -->/g;
6868

6969
const transformedContent = content.replace(tabBlockRegex, (match, tabsContent) => {
70-
// Extract individual tabs
71-
const tabRegex = /<!-- TAB:([^:]+)(?::default)? -->\n([\s\S]*?)(?=<!-- TAB:|<!-- TABS:END)/g;
70+
// Split content by TAB markers to extract individual tabs
71+
const tabSections = tabsContent.split(/<!-- TAB:/);
7272
const tabs = [];
73-
let tabMatch;
7473

75-
while ((tabMatch = tabRegex.exec(tabsContent)) !== null) {
76-
const label = tabMatch[1].trim();
77-
const content = tabMatch[2].trim();
78-
const isDefault = match.includes(`<!-- TAB:${label}:default -->`);
79-
tabs.push({ label, content, isDefault });
74+
// Skip first element (empty or content before first tab)
75+
for (let i = 1; i < tabSections.length; i++) {
76+
const section = tabSections[i];
77+
78+
// Extract label and check for :default marker
79+
const labelMatch = section.match(/^([^:]+?)(?::default)?\s*-->\n([\s\S]*?)$/);
80+
if (labelMatch) {
81+
const label = labelMatch[1].trim();
82+
const content = labelMatch[2].trim();
83+
const isDefault = section.includes(':default -->');
84+
tabs.push({ label, content, isDefault });
85+
}
8086
}
8187

8288
if (tabs.length === 0) return match;
@@ -115,14 +121,15 @@ function applyBasicMdxFixes(content) {
115121
// Then apply other MDX fixes
116122
return transformed
117123
// Convert GitHub-style callouts to Docusaurus admonitions
118-
.replace(/^> \[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*\n((?:> .*\n?)*)/gm, (match, type, content) => {
124+
.replace(/^> \[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|REQUIREMENTS)\]\s*\n((?:> .*\n?)*)/gm, (match, type, content) => {
119125
// Map GitHub callout types to Docusaurus admonition types
120126
const typeMap = {
121127
'NOTE': 'note',
122128
'TIP': 'tip',
123129
'IMPORTANT': 'info',
124130
'WARNING': 'warning',
125-
'CAUTION': 'danger'
131+
'CAUTION': 'danger',
132+
'REQUIREMENTS': 'info' // Map to info admonition
126133
};
127134

128135
const docusaurusType = typeMap[type] || type.toLowerCase();

0 commit comments

Comments
 (0)