Skip to content

Commit 7948562

Browse files
pagetabs: initial page tabs (#1500)
1 parent 569d99d commit 7948562

15 files changed

Lines changed: 1139 additions & 1 deletion

File tree

znai-docs/znai/layout/page-tabs.md

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# Primary Use Case
2+
3+
When your documentation covers the same concepts across multiple languages or platforms,
4+
you can use `tab-content` to make the entire page switchable. Unlike regular `tabs` which require
5+
wrapping each difference in a tabs fence, `tab-content` lets you sprinkle tab-specific content
6+
throughout the page. Shared content stays as regular markdown.
7+
8+
This page itself uses `tab-content` — notice the tabs at the top. Switch between them to see
9+
how content changes across sections while shared text remains.
10+
11+
Below is a demo, except the final [Definition](#definition) section.
12+
13+
# Project Setup
14+
15+
Every project needs an editor configuration. Create a workspace settings file in your project root.
16+
17+
`````tab-content "VS Code"
18+
Create `.vscode/settings.json` in your project root:
19+
20+
```json
21+
{
22+
"editor.formatOnSave": true,
23+
"editor.tabSize": 4,
24+
"files.trimTrailingWhitespace": true
25+
}
26+
```
27+
28+
Note: VS Code will automatically detect these settings when you open the folder.
29+
`````
30+
31+
`````tab-content Emacs
32+
Create `.dir-locals.el` in your project root:
33+
34+
```elisp
35+
((nil . ((indent-tabs-mode . nil)
36+
(tab-width . 4)
37+
(fill-column . 100))))
38+
```
39+
40+
Note: Emacs will automatically load these settings when visiting any file in the directory.
41+
`````
42+
43+
# Build Configuration
44+
45+
Set up the build tool for your project. All editors use the same underlying build system,
46+
but the integration differs.
47+
48+
`````tab-content "VS Code"
49+
Create `.vscode/tasks.json` to integrate the build:
50+
51+
````tabs
52+
Java:
53+
```json
54+
{
55+
"version": "2.0.0",
56+
"tasks": [{
57+
"label": "build",
58+
"type": "shell",
59+
"command": "mvn compile",
60+
"group": "build"
61+
}]
62+
}
63+
```
64+
65+
C++:
66+
```json
67+
{
68+
"version": "2.0.0",
69+
"tasks": [{
70+
"label": "build",
71+
"type": "shell",
72+
"command": "cmake --build build/",
73+
"group": "build"
74+
}]
75+
}
76+
```
77+
````
78+
79+
Use `Ctrl+Shift+B` to run the build task.
80+
`````
81+
82+
`````tab-content Emacs
83+
Configure `compile-command` in `.dir-locals.el`:
84+
85+
````tabs
86+
Java:
87+
```elisp
88+
((nil . ((compile-command . "mvn compile"))))
89+
```
90+
91+
C++:
92+
```elisp
93+
((nil . ((compile-command . "cmake --build build/"))))
94+
```
95+
````
96+
97+
Use `M-x compile` to run the build.
98+
`````
99+
100+
# Debugging
101+
102+
All projects benefit from proper debug configuration. Breakpoints, watch expressions,
103+
and stepping through code work the same conceptually — but the configuration differs per editor.
104+
105+
`````tab-content "VS Code"
106+
Create `.vscode/launch.json`:
107+
108+
````tabs
109+
Java:
110+
```json
111+
{
112+
"version": "0.2.0",
113+
"configurations": [{
114+
"type": "java",
115+
"name": "Debug Main",
116+
"request": "launch",
117+
"mainClass": "com.example.Main"
118+
}]
119+
}
120+
```
121+
122+
C++:
123+
```json
124+
{
125+
"version": "0.2.0",
126+
"configurations": [{
127+
"type": "cppdbg",
128+
"name": "Debug Main",
129+
"request": "launch",
130+
"program": "${workspaceFolder}/build/main"
131+
}]
132+
}
133+
```
134+
````
135+
136+
Press `F5` to start debugging.
137+
`````
138+
139+
`````tab-content Emacs
140+
````tabs
141+
Java:
142+
Use `dap-mode` with the Java debug adapter:
143+
144+
```elisp
145+
(require 'dap-java)
146+
(dap-register-debug-template "Debug Main"
147+
(list :type "java"
148+
:request "launch"
149+
:mainClass "com.example.Main"))
150+
```
151+
152+
C++:
153+
Use `dap-mode` with `gdb`:
154+
155+
```elisp
156+
(require 'dap-gdb-lldb)
157+
(dap-register-debug-template "Debug Main"
158+
(list :type "cppdbg"
159+
:request "launch"
160+
:program "${workspaceFolder}/build/main"))
161+
```
162+
````
163+
164+
Use `M-x dap-debug` to start a debug session.
165+
`````
166+
167+
# Definition
168+
169+
Use `tab-content` fence blocks with a tab id to mark sections of content that are specific to a tab.
170+
Content outside of `tab-content` blocks is always visible regardless of which tab is selected.
171+
172+
```````markdown
173+
Shared content here is always visible.
174+
175+
```tab-content "VS Code"
176+
Press `F5` to start debugging.
177+
```
178+
179+
180+
```tab-content Emacs
181+
Use `M-x dap-debug` to start a debug session.
182+
```
183+
184+
More shared content here.
185+
```````
186+
187+
When a page contains `tab-content` blocks, tabs automatically appear at the top of the page.
188+
189+
Regular `tabs` fence blocks can be used inside `tab-content` for additional sub-grouping.
190+
The global page tabs and regular tabs operate independently.
191+
192+
```````markdown
193+
Shared content here is always visible.
194+
195+
`````tab-content "VS Code"
196+
```tabs
197+
Java: hello VS Code Java
198+
C++: hello Vs Code C++
199+
```
200+
`````
201+
202+
203+
`````tab-content Emacs
204+
```tabs
205+
Java: hello Emacs Java
206+
C++: hello Emacs C++
207+
```
208+
`````
209+
210+
More shared content here.
211+
```````
212+
213+
---
214+
215+
Shared content here is always visible.
216+
217+
`````tab-content "VS Code"
218+
```tabs
219+
Java: hello VS Code Java
220+
C++: hello Vs Code C++
221+
```
222+
`````
223+
224+
225+
`````tab-content Emacs
226+
```tabs
227+
Java: hello Emacs Java
228+
C++: hello Emacs C++
229+
```
230+
`````
231+
232+
More shared content here.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add: Global Tabs (per page). Simplified way to provide common and unique content per Editor/Language/Tool

znai-docs/znai/toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ visuals
5959
asciinema
6060
layout
6161
tabs
62+
page-tabs
6263
tables
6364
columns
6465
templates

znai-reactjs/src/doc-elements/DefaultElementsLibrary.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import presentationGraphVizSvg from './graphviz/PresentationGraphVizSvg'
4343
import DocumentationGraphVizFlow from './graphviz/DocumentationGraphVizFlow'
4444
import Table from './table/Table'
4545
import {presentationTabsHandler, Tabs} from './tabs/Tabs'
46+
import TabContent from './tabs/TabContent'
4647
import {Columns, presentationColumnsHandler} from './columns/Columns'
4748
import { Icon } from './icons/Icon'
4849
import KeyboardShortcut from './keyboard/KeyboardShortcut'
@@ -186,6 +187,8 @@ library.FootnoteBackLinks = FootnoteBackLinks;
186187
library.Tabs = Tabs
187188
presentationElementHandlers.Tabs = presentationTabsHandler
188189

190+
library.TabContent = TabContent
191+
189192
library.Columns = Columns
190193
presentationElementHandlers.Columns = presentationColumnsHandler
191194

0 commit comments

Comments
 (0)