Skip to content

Commit 8b95bd3

Browse files
committed
[lldb] Enable markdown support for documentation
This enables support for writing LLDB documentation in markdown in addition to reStructured text. We already had documentation written in markdown (StructuredDataPlugins and DarwinLog) which will now also be available on the website.
1 parent 0156914 commit 8b95bd3

File tree

5 files changed

+474
-297
lines changed

5 files changed

+474
-297
lines changed

lldb/docs/conf.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,24 @@
3232
templates_path = ['_templates']
3333

3434
# The suffix of source filenames.
35-
source_suffix = '.rst'
35+
source_suffix = {
36+
'.rst': 'restructuredtext',
37+
}
38+
39+
try:
40+
import recommonmark
41+
except ImportError:
42+
# manpages do not use any .md sources
43+
if not tags.has('builder-man'):
44+
raise
45+
else:
46+
import sphinx
47+
if sphinx.version_info >= (3, 0):
48+
# This requires 0.5 or later.
49+
extensions.append('recommonmark')
50+
else:
51+
source_parsers = {'.md': 'recommonmark.parser.CommonMarkParser'}
52+
source_suffix['.md'] = 'markdown'
3653

3754
# The encoding of source files.
3855
#source_encoding = 'utf-8-sig'
@@ -233,6 +250,19 @@
233250
# If true, show URL addresses after external links.
234251
#man_show_urls = False
235252

253+
def process_md(name):
254+
file_subpath = os.path.join(command_guide_subpath, name)
255+
with open(os.path.join(command_guide_path, name)) as f:
256+
title = f.readline().rstrip('\n')
257+
258+
m = re.match(r'^# (\S+) - (.+)$', title)
259+
if m is None:
260+
print("error: invalid title in %r "
261+
"(expected '# <name> - <description>')" % file_subpath,
262+
file=sys.stderr)
263+
else:
264+
man_pages.append((file_subpath.replace('.md',''), m.group(1),
265+
m.group(2), man_page_authors, 1))
236266

237267
# -- Options for Texinfo output ------------------------------------------------
238268

lldb/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ interesting areas to contribute to lldb.
146146
resources/test
147147
resources/bots
148148
resources/reproducers
149+
resources/structureddataplugins
149150
resources/sbapi
150151
resources/caveats
151152

0 commit comments

Comments
 (0)