Add docs recipe for generating documentation from the headers.

Note that since all the headers are not documented yet, this will fail
because an undocumented function is a fatal error in hdoc.
This commit is contained in:
Jordan Bancino 2023-04-27 18:39:05 +00:00
parent 9880aac674
commit 9292f1d9da
4 changed files with 55 additions and 3 deletions

View file

@ -370,6 +370,8 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
strcmp(word, "elif") == 0 || strcmp(word, "elif") == 0 ||
strcmp(word, "error") == 0) strcmp(word, "error") == 0)
{ {
int pC;
Free(word); Free(word);
expr->data.text[i] = ' '; expr->data.text[i] = ' ';
i++; i++;
@ -394,8 +396,7 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
return; return;
} }
/* TODO: Handle backslash escapes */ if (c == '\n' && pC != '\\')
if (c == '\n')
{ {
expr->data.text[i] = '\0'; expr->data.text[i] = '\0';
expr->state.lineNo++; expr->state.lineNo++;
@ -406,6 +407,8 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
expr->data.text[i] = c; expr->data.text[i] = c;
i++; i++;
} }
pC = c;
} }
} }
else if (strcmp(word, "else") == 0 || else if (strcmp(word, "else") == 0 ||

View file

@ -24,6 +24,35 @@
#ifndef TELODENDRIA_INT_H #ifndef TELODENDRIA_INT_H
#define TELODENDRIA_INT_H #define TELODENDRIA_INT_H
/***
* @Nm Int
* @Nd Fixed-width integer types.
* @Dd April 27 2023
*
* This header provides cross-platform, fixed-width integer types.
* Specifically, it uses preprocessor magic to define the following
* types:
* .Bl -bullet -offset indent
* .It
* Int8 and UInt8
* .It
* Int16 and UInt16
* .It
* Int32 and UInt32
* .El
* .Pp
* Note that there is no 64-bit integer type, because the ANSI C
* standard makes no guarantee that such a type will exist, even
* though it does on most platforms.
* .Pp
* The reason Telodendria provides its own header for this is
* because ANSI C does not define fixed-width types, and while it
* should be safe to rely on C99 fixed-width types in most cases,
* there may be cases where even that is not possible.
*
* @ignore-typedefs
*/
#include <limits.h> #include <limits.h>
#define BIT64_MAX 18446744073709551615 #define BIT64_MAX 18446744073709551615

View file

@ -108,6 +108,22 @@ setsubst() {
rm "$SED" rm "$SED"
} }
recipe_docs() {
mkdir -p build/man/man3
for header in $(find src -name '*.h'); do
basename=$(basename "$header")
man=$(echo "build/man/man3/$basename" | sed -e 's/\.h$/\.3/')
if [ $(mod_time "$header") -ge $(mod_time "$man") ]; then
echo "DOC $basename"
if ! hdoc -D Os=Telodendria -i "$header" -o "$man"; then
exit 1
fi
fi
done
}
# Build the source code, and generate the 'build/telodendria' # Build the source code, and generate the 'build/telodendria'
# binary. # binary.
recipe_build() { recipe_build() {
@ -292,7 +308,6 @@ recipe_release() {
# really picky about how patches look, but this is how we like them # really picky about how patches look, but this is how we like them
# best. Makes them easy to read. # best. Makes them easy to read.
recipe_patch() { recipe_patch() {
# If the user has not set their MXID, try to deduce one from # If the user has not set their MXID, try to deduce one from
# their system. # their system.
if [ -z "$MXID" ]; then if [ -z "$MXID" ]; then

View file

@ -242,6 +242,11 @@ main(int argc, char **argv)
} }
break; break;
case HP_TYPEDEF: case HP_TYPEDEF:
if (HashMapGet(registers, "ignore-typedefs"))
{
break;
}
if (!isDocumented) if (!isDocumented)
{ {
StreamPrintf(StreamStderr(), StreamPrintf(StreamStderr(),