Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/buildman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ jobs:
- run: |
mkdir output

- uses: docker://pandoc/latex:3.6.3
with:
args: --output=output/manual.html man/manual.md

- uses: docker://pandoc/latex:3.6.3
with:
args: --output=output/manual.pdf man/manual.md

- uses: docker://pandoc/latex:3.6.3
with:
args: --output=output/manual-premium.pdf man/manual-premium.md
# buildman.sh runs in the pandoc container. The LaTeX packages used by manual-style.tex
# and the DejaVu fonts are not included in the image.
- name: Build manuals
run: |
docker run --rm -v "$GITHUB_WORKSPACE:/data" -w /data/man --entrypoint sh pandoc/latex:3.6.3 -c '
set -e
tlmgr --repository https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2024/tlnet-final install titlesec newverbs
apk add --no-cache font-dejavu
./buildman.sh
chown -R '"$(id -u):$(id -g)"' .'
cp man/*.pdf man/*.html man/manual.css output/

- uses: actions/upload-artifact@v7
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ stage

# Manual folder
/man/manual.log
/man/appendix-*.md
/man/manual.tex
/man/*.pdf
/man/*.html
Expand Down
15 changes: 13 additions & 2 deletions man/build-html.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#!/bin/sh
echo Building $1.html
pandoc $1.md -o $1.html -s --number-sections --toc --css manual.css
# Usage:
# ./build-html.sh NAME # NAME.md -> NAME.html
# ./build-html.sh NAME INPUT... [pandoc options]
# # INPUT... -> NAME.html
name=$1
shift
if [ $# -eq 0 ]; then
set -- "$name.md"
fi
echo Building $name.html
pandoc "$@" -o $name.html -s --number-sections --toc --css manual.css \
--lua-filter=filters/include-files.lua \
--lua-filter=filters/manual.lua
18 changes: 15 additions & 3 deletions man/build-pdf.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#!/bin/sh
# Usage:
# ./build-pdf.sh NAME # NAME.md -> NAME.pdf
# ./build-pdf.sh NAME INPUT... [pandoc options]
# # INPUT... -> NAME.pdf
#
# This uses installed fonts, which vary between systems
# Segoe UI and Consolas are standard in Windows 10, DejaVu is more common on Linux
echo Building $1.pdf
name=$1
shift
if [ $# -eq 0 ]; then
set -- "$name.md"
fi
echo Building $name.pdf

MainFont="Segoe UI"
MonoFont="Consolas"
Expand All @@ -20,7 +30,7 @@ fi

# echo Using $MainFont / $MonoFont

pandoc $1.md -o $1.pdf -s --number-sections --toc \
pandoc "$@" -o $name.pdf -s --number-sections --toc \
--pdf-engine=xelatex \
--listings \
-f markdown \
Expand All @@ -29,4 +39,6 @@ pandoc $1.md -o $1.pdf -s --number-sections --toc \
-V geometry:a4paper \
-V geometry:margin=2.4cm \
-V subparagraph \
-H manual-style.tex
-H manual-style.tex \
--lua-filter=filters/include-files.lua \
--lua-filter=filters/manual.lua
14 changes: 12 additions & 2 deletions man/buildman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
# sudo apt-get install pandoc texlive-latex-base texlive-fonts-recommended texlive-latex-extra
# For Windows you can use the MiKTeX installer https://miktex.org/download

./build-pdf.sh manual
./build-html.sh manual
set -e

# The documentation of all checkers is added as an appendix
./make-appendix.sh "Checkers" checkers/*.md > appendix-checkers.md

# manual.md contains the content for both the open source and the premium
# manual, the metadata file selects which one is built.
./build-pdf.sh manual manual.md appendix-checkers.md --metadata-file=manual-opensource.yaml
./build-html.sh manual manual.md appendix-checkers.md --metadata-file=manual-opensource.yaml

./build-pdf.sh manual-premium manual.md appendix-checkers.md --metadata-file=manual-premium.yaml
./build-html.sh manual-premium manual.md appendix-checkers.md --metadata-file=manual-premium.yaml

./build-pdf.sh reference-cfg-format
./build-html.sh reference-cfg-format
2 changes: 1 addition & 1 deletion man/checkers/checkLibraryUseIgnore.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# checkLibraryUseIgnore

**Message**: --check-library: Function f() should have <use>/<leak-ignore> configuration<br/>
**Message**: `--check-library: Function f() should have <use>/<leak-ignore> configuration`<br/>
**Category**: Configuration<br/>
**Severity**: Information<br/>
**Language**: C/C++
Expand Down
2 changes: 1 addition & 1 deletion man/checkers/leakUnsafeArgAlloc.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# leakUnsafeArgAlloc

**Message**: Unsafe allocation. If shared_ptr() throws, memory could be leaked. Use make_shared<T>() instead.<br/>
**Message**: `Unsafe allocation. If shared_ptr() throws, memory could be leaked. Use make_shared<T>() instead.`<br/>
**Category**: Correctness<br/>
**Severity**: Warning (inconclusive)<br/>
**Language**: C++
Expand Down
3 changes: 3 additions & 0 deletions man/checkers/premium-misra-config.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
::: {.content-visible when-profile="premium"}

# premium-misra-config

**Message**: Unknown constant x, please review cppcheck options<br/>
Expand Down Expand Up @@ -48,3 +50,4 @@ If the code depends on preprocessor macros that are not defined:
cppcheck -DMISSING_MACRO=value file.c
```

:::
4 changes: 4 additions & 0 deletions man/checkers/unknownMacro.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ cppcheck should just ignore the keyword then an `-DKEYWORD=` option is suggested

Warning:

```
canu-2.2/src/seqrequester/src/seqrequester/generate.H:72:41: error: There is an unknown macro here somewhere. Configuration is required. If F_U64 is a macro then please configure it. [unknownMacro]
```

Fix:

Expand All @@ -53,7 +55,9 @@ void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks)

Warning:

```
botan-2.19.5+dfsg/src/lib/block/aes/aes_power8/aes_power8.cpp:103:1: error: There is an unknown macro here somewhere. Configuration is required. If BOTAN_FUNC_ISA is a macro then please configure it. [unknownMacro]
```

Fix:

Expand Down
21 changes: 21 additions & 0 deletions man/filters/include-files.LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Pandoc Extensions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
128 changes: 128 additions & 0 deletions man/filters/include-files.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
--- include-files.lua – filter to include Markdown files
---
--- Copyright: © 2019–2021 Albert Krewinkel
--- License: MIT – see LICENSE file for details

-- Module pandoc.path is required and was added in version 2.12
PANDOC_VERSION:must_be_at_least '2.12'

local pandoc = require 'pandoc'
local List = require 'pandoc.List'
local path = require 'pandoc.path'
local system = require 'pandoc.system'

--- Get include auto mode
local include_auto = false
local function get_vars (meta)
if meta['include-auto'] then
include_auto = true
end
end

--- Keep last heading level found
local last_heading_level = 0
local function update_last_level(header)
last_heading_level = header.level
end

--- Update contents of included file
local function update_contents(blocks, shift_by, include_path)
local update_contents_filter = {
-- Shift headings in block list by given number
Header = function (header)
if shift_by then
header.level = header.level + shift_by
end
return header
end,
-- If link paths are relative then prepend include file path
Link = function (link)
if path.is_relative(link.target) and string.sub(path.filename(link.target), 1, 1) ~= '#' and not string.find(link.target, "https?://") then
link.target = path.normalize(path.join({include_path, link.target}))
end
return link
end,
-- If image paths are relative then prepend include file path
Image = function (image)
if path.is_relative(image.src) then
image.src = path.normalize(path.join({include_path, image.src}))
end
return image
end,
-- Update path for include-code-files.lua filter style CodeBlocks
CodeBlock = function (cb)
if cb.attributes.include and path.is_relative(cb.attributes.include) then
cb.attributes.include =
path.normalize(path.join({include_path, cb.attributes.include}))
end
return cb
end
}

return pandoc.walk_block(pandoc.Div(blocks), update_contents_filter).content
end

--- Filter function for code blocks
local transclude
function transclude (cb)
-- ignore code blocks which are not of class "include".
if not cb.classes:includes 'include' then
return
end

-- Markdown is used if this is nil.
local format = cb.attributes['format']

-- Attributes shift headings
local shift_heading_level_by = 0
local shift_input = cb.attributes['shift-heading-level-by']
if shift_input then
shift_heading_level_by = tonumber(shift_input)
else
if include_auto then
-- Auto shift headings
shift_heading_level_by = last_heading_level
end
end

--- keep track of level before recusion
local buffer_last_heading_level = last_heading_level

local blocks = List:new()
for line in cb.text:gmatch('[^\n]+') do
if line:sub(1,2) ~= '//' then
local fh = io.open(line)
if not fh then
io.stderr:write("Cannot open file " .. line .. " | Skipping includes\n")
else
-- read file as the given format with global reader options
local contents = pandoc.read(
fh:read '*a',
format,
PANDOC_READER_OPTIONS
).blocks
last_heading_level = 0
-- recursive transclusion
contents = system.with_working_directory(
path.directory(line),
function ()
return pandoc.walk_block(
pandoc.Div(contents),
{ Header = update_last_level, CodeBlock = transclude }
)
end).content
--- reset to level before recursion
last_heading_level = buffer_last_heading_level
blocks:extend(update_contents(contents, shift_heading_level_by,
path.directory(line)))
fh:close()
end
end
end
return blocks
end

return {
{ Meta = get_vars },
{ Header = update_last_level, CodeBlock = transclude }
}
Loading
Loading