Skip to content

Commit 4974f67

Browse files
committed
Scdoc: new parser
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 9716c31 commit 4974f67

File tree

14 files changed

+492
-0
lines changed

14 files changed

+492
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--sort=no
2+
--fields=+en
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
foo input.scd /^foo(1)$/;" t line:1 end:10
2+
a input.scd /^# a$/;" s line:6 title:foo end:7
3+
c input.scd /^# c$/;" s line:8 title:foo end:10
4+
b input.scd /^## b$/;" S line:10 section:foo""c end:10
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
foo(1)
2+
3+
## This one should not be extracted
4+
because there is no section owns this.
5+
6+
# a
7+
8+
# c
9+
10+
## b
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
input.md is taken from https://git.sr.ht/~sircmpwn/scdoc/tree/master/item/scdoc.5.scd .
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--sort=no
2+
--fields=+ne
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SCDOC input.scd /^SCDOC(5)$/;" t line:1 end:213
2+
NAME input.scd /^# NAME$/;" s line:3 title:SCDOC end:6
3+
SYNTAX input.scd /^# SYNTAX$/;" s line:7 title:SCDOC end:200
4+
Preamble input.scd /^## Preamble$/;" S line:11 section:SCDOC""SYNTAX end:23
5+
Section headers input.scd /^## Section headers$/;" S line:24 section:SCDOC""SYNTAX end:33
6+
Paragraphs input.scd /^## Paragraphs$/;" S line:34 section:SCDOC""SYNTAX end:37
7+
Line breaks input.scd /^## Line breaks$/;" S line:38 section:SCDOC""SYNTAX end:44
8+
Formatting input.scd /^## Formatting$/;" S line:45 section:SCDOC""SYNTAX end:49
9+
Indentation input.scd /^## Indentation$/;" S line:50 section:SCDOC""SYNTAX end:61
10+
Lists input.scd /^## Lists$/;" S line:62 section:SCDOC""SYNTAX end:98
11+
Numbered lists input.scd /^## Numbered lists$/;" S line:99 section:SCDOC""SYNTAX end:115
12+
Tables input.scd /^## Tables$/;" S line:116 section:SCDOC""SYNTAX end:173
13+
Literal text input.scd /^## Literal text$/;" S line:174 section:SCDOC""SYNTAX end:192
14+
Comments input.scd /^## Comments$/;" S line:193 section:SCDOC""SYNTAX end:200
15+
CONVENTIONS input.scd /^# CONVENTIONS$/;" s line:201 title:SCDOC end:204
16+
SEE ALSO input.scd /^# SEE ALSO$/;" s line:205 title:SCDOC end:208
17+
AUTHORS input.scd /^# AUTHORS$/;" s line:209 title:SCDOC end:213
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
SCDOC(5)
2+
3+
# NAME
4+
5+
scdoc - document format for writing manual pages
6+
7+
# SYNTAX
8+
9+
Input files must use the UTF-8 encoding.
10+
11+
## Preamble
12+
13+
Each scdoc file must begin with the following preamble:
14+
15+
_NAME_(_section_) ["left\_footer" ["center\_header"]]
16+
17+
_NAME_ is the name of the man page you are writing, and _section_ is the section
18+
you're writing for (see _man_(1) for information on manual sections).
19+
20+
_left\_footer_ and _center\_header_ are optional arguments which set the text
21+
positioned at those locations in the generated man page, and *must* be
22+
surrounded with double quotes.
23+
24+
## Section headers
25+
26+
Each section of your man page should begin with something similar to the
27+
following:
28+
29+
# HEADER NAME
30+
31+
Subsection headers are also understood - use two hashes. Each header must have
32+
an empty line on either side.
33+
34+
## Paragraphs
35+
36+
Begin a new paragraph with an empty line.
37+
38+
## Line breaks
39+
40+
Insert a line break by ending a line with \+\+.
41+
42+
The result looks++
43+
like this.
44+
45+
## Formatting
46+
47+
Text can be made *bold* or _underlined_ with asterisks and underscores: \*bold\*
48+
or \_underlined\_. Underscores in the_middle_of_words will be disregarded.
49+
50+
## Indentation
51+
52+
You may indent lines with tab characters (*\\t*) to indent them by 4 spaces in
53+
the output. Indented lines may not contain headers.
54+
55+
The result looks something like this.
56+
57+
You may use multiple lines and most _formatting_.
58+
59+
Deindent to return to normal, or indent again to increase your indentation
60+
depth.
61+
62+
## Lists
63+
64+
You may start bulleted lists with dashes (-), like so:
65+
66+
```
67+
- Item 1
68+
- Item 2
69+
- Subitem 1
70+
- Subitem 2
71+
- Item 3
72+
```
73+
74+
The result looks like this:
75+
76+
- Item 1
77+
- Item 2
78+
- Subitem 1
79+
- Subitem 2
80+
- Item 3
81+
82+
You may also extend long entries onto another line by giving it the same indent
83+
level, plus two spaces. They will be rendered as a single list entry.
84+
85+
```
86+
- Item 1 is pretty long so let's
87+
break it up onto two lines
88+
- Item 2 is shorter
89+
- But its children can go on
90+
for a while
91+
```
92+
93+
- Item 1 is pretty long so let's
94+
break it up onto two lines
95+
- Item 2 is shorter
96+
- But its children can go on
97+
for a while
98+
99+
## Numbered lists
100+
101+
Numbered lists are similar to normal lists, but begin with periods (.) instead
102+
of dashes (-), like so:
103+
104+
```
105+
. Item 1
106+
. Item 2
107+
. Item 3,
108+
with multiple lines
109+
```
110+
111+
. Item 1
112+
. Item 2
113+
. Item 3,
114+
with multiple lines
115+
116+
## Tables
117+
118+
To begin a table, add an empty line followed by any number of rows.
119+
120+
Each line of a table should start with | or : to start a new row or column
121+
respectively (or space to continue the previous cell on multiple lines),
122+
followed by [ or - or ] to align the contents to the left, center, or right,
123+
followed by a space and the contents of that cell. You may use a space instead
124+
of an alignment specifier to inherit the alignment of the same column in the
125+
previous row. Each row must have the same number of columns; empty columns are
126+
permitted.
127+
128+
The first character of the first row is not limited to | and has special
129+
meaning. [ will produce a table with borders around each cell. | will produce a
130+
table with no borders. ] will produce a table with one border around the whole
131+
table.
132+
133+
To conclude your table, add an empty line after the last row.
134+
135+
```
136+
[[ *Foo*
137+
:- _Bar_
138+
:-
139+
| *Row 1*
140+
: Hello
141+
:] world!
142+
| *Row 2*
143+
: こんにちは
144+
: 世界
145+
!
146+
```
147+
148+
[[ *Foo*
149+
:- _Bar_
150+
:-
151+
| *Row 1*
152+
: Hello
153+
:] world!
154+
| *Row 2*
155+
: こんにちは
156+
: 世界
157+
!
158+
159+
You may also cause columns to expand to fill the available space with < (left
160+
align), = (center align), and > (right align), like so:
161+
162+
```
163+
[[ *Normal column*
164+
:< Expanded column
165+
| *Foo*
166+
: Bar
167+
```
168+
169+
[[ *Normal column*
170+
:< Expanded column
171+
| *Foo*
172+
: Bar
173+
174+
## Literal text
175+
176+
You may turn off scdoc formatting and output literal text with escape codes and
177+
literal blocks. Inserting a \\ into your source will cause the subsequent symbol
178+
to be treated as a literal and copied directly to the output. You may also make
179+
blocks of literal syntax like so:
180+
181+
```
182+
\```
183+
_This formatting_ will *not* be interpreted by scdoc.
184+
\```
185+
```
186+
187+
These blocks will be indented one level. Note that literal text is shown
188+
literally in the man viewer - that is, it's not a means for inserting your own
189+
roff macros into the output. Note that \\ is still interpreted within literal
190+
blocks, which for example can be useful to output \``` inside of a literal
191+
block.
192+
193+
## Comments
194+
195+
Lines beginning with ; and a space are ignored.
196+
197+
```
198+
; This is a comment
199+
```
200+
201+
# CONVENTIONS
202+
203+
By convention, all scdoc documents should be hard wrapped at 80 columns.
204+
205+
# SEE ALSO
206+
207+
_scdoc_(1)
208+
209+
# AUTHORS
210+
211+
Maintained by Drew DeVault <[email protected]>. Up-to-date sources can be found at
212+
https://git.sr.ht/~sircmpwn/scdoc and bugs/patches can be submitted by email to
213+
~sircmpwn/public-[email protected].

docs/news/HEAD.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ New parsers
4545
* SELinuxIntefae *M4 based subparser*
4646
* SELinuxTypeEnforcement *optlib*
4747
* PythonEntryPoints *subparser*
48+
* Scdoc *optlib*
4849

4950
Changes about parser specific kinds, roles, fields, and extras
5051
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

main/parsers_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
ShParser, \
177177
SlangParser, \
178178
SmlParser, \
179+
ScdocParser, \
179180
SqlParser, \
180181
SystemdUnitParser, \
181182
SystemTapParser, \

0 commit comments

Comments
 (0)