From 528e793ce395474ba116ecd9610fe04c959e3e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 22 Nov 2017 12:26:51 +0100 Subject: [exdoc] Support Doxygen-style code blocks. This doesn't support the full syntax, but it's enough for our needs. --- docs/api-style.css | 10 ++++++++++ docs/exdoc | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/api-style.css b/docs/api-style.css index 1f6483919cf..f8f9c27a4ab 100644 --- a/docs/api-style.css +++ b/docs/api-style.css @@ -43,6 +43,16 @@ line-height: 0px; } + .mapi-codeblock { + display: block; + padding: 5pt 5pt; + margin: 10pt; + white-space: pre; + font-family: monospace; + border: 1px solid rgba(233,233,233,1); + background-color: rgba(249,249,249,1); + } + .mapi-entry code { border: none; background-color: transparent; diff --git a/docs/exdoc b/docs/exdoc index 38321c19c8b..38f1cc5e1b1 100644 --- a/docs/exdoc +++ b/docs/exdoc @@ -124,6 +124,7 @@ sub process_function { my $body = ''; my $returns = ''; my $prototype = ''; + my $codeblock = 'false'; while (<$file>) { @@ -180,8 +181,16 @@ sub process_function { chomp; s/^ +\*//; - # Replace blank lines with paragraph breaks. - $_ = '

' if /^\s*$/; + if (/\s*\\code$/) { + $codeblock = 'true'; + } elsif (/\s*\\endcode$/) { + $codeblock = 'false'; + } + + # Replace blank lines with paragraph breaks if we're not in a code block. + if (/^\s*$/) { + $_ = '

' if $codeblock eq 'false'; + } if ($section == $PARAMETER_SECTION) { if (/\s*\\param +(\w+)(.*)/) { @@ -249,6 +258,8 @@ sub process_formatting { warn "$file_path:$current_line: Old-style monodoc notation '`code`' used\n" if s{\`((?!api:)[:.\w\*]+)\`}{$1}g && $WARNINGS; s{\\c +(\S+(?$1}g; + s{\\code}{

}g;
+    s{\\endcode}{
}g; $$content = $_; } -- cgit v1.2.3