From 686166d5e6c884cd75c0e2ef602a13cc6e04fd2c Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 13 Jan 2006 08:09:06 +0100 Subject: [PATCH] Various api doc related fixes and cleanups --- doc/Makefile | 7 +++--- doc/tools/code2doc | 62 ++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index a56f3ed7..631d5687 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -95,7 +95,8 @@ api/$(2).txt: $(1) API_TXT += api/$(2).txt endef -$(foreach api,$(API),$(eval $(call api_doc,$(api),$(shell sed -n 's/.*API Doc\s*::\s*\([^ ]*\).*/\1/p' < $(api)),))) +api_name = $(shell sed -n 's/.*API Doc\s*::\s*\([^ ]*\).*/\1/p' < $(1)) +$(foreach api,$(API),$(eval $(call api_doc,$(api),$(call api_name,$(api))))) ## Se the default doc rules @@ -167,11 +168,11 @@ man_hack = sed "s/^\(\.TH \"ELINKS[^\"]*\" [0-9] \).*/\1\"$(1)\" \"$(MAN_DATE)\" %.html: %.txt asciidoc.conf $(call cmd,asciidoc,xhtml11) - @-sed -n 's/include::\(.*\)\[.*/$@: \1/p' < $< > .deps/$@ + @-sed -n 's#include::\(.*\)\[.*#$@: \1#p' < $< > .deps/$(@F) %.xml: %.txt asciidoc.conf $(call cmd,asciidoc,docbook) - @-sed -n 's/include::\(.*\)\[.*/$@: \1/p' < $< > .deps/$@ + @-sed -n 's#include::\(.*\)\[.*#$@: \1#p' < $< > .deps/$(@F) %.1: %.1.xml $(call cmd,xmlto,man) diff --git a/doc/tools/code2doc b/doc/tools/code2doc index 12c64d4d..979c8f19 100755 --- a/doc/tools/code2doc +++ b/doc/tools/code2doc @@ -59,10 +59,13 @@ while (<>) my $orig_title = $title; - if (not /^#define\s/) { - while (not /(struct|enum|typedef|[^=])*[\s*](\w+).*[\[:,;{]/) { - $_ .= <>; - } + + # Combine multi-line declarations to one. Break at empty + # for #define ... + while (not /(struct|enum|typedef|[^=])*[\s*](\w+).*[\[:,;{]/) { + my $line = $_; + $_ .= <>; + last if $_ eq $line } if (/struct\s+(\w+)\s*{/) { @@ -73,36 +76,35 @@ while (<>) $title = "enum:$1" . "[$title]"; $idpath = ""; - } elsif (/#define\s+(\w+)[(]/) { + } elsif (/#define/) { + if (/#define\s+(\w+)[(]/) { + $title = "func:$1" . "[$title]"; + } elsif (/#define\s+(\w+)/) { + $title = "macro:$1" . "[$title]"; + } + $idpath = ""; + + } elsif (/typedef/) { + if (/.*\(\*(\w+)\)\(/) { + $title = "typedef:$1" . "[$title]"; + } elsif (/typedef.*\s(\w+);/) { + $title = "typedef:$1" . "[$title]"; + } + $idpath = ""; + + } elsif (/.*[\s*](\w+)\(/) { $title = "func:$1" . "[$title]"; $idpath = ""; - } elsif (/#define\s+(\w+)/) { - $title = "macro:$1" . "[$title]"; - $idpath = ""; + } elsif (/.*\(\*(\w+)\)\(/) { + $body = "#newline#" . $title if not $body; + $title = "id:[$idpath$1]::"; + $indent = "\t"; - } else { - if (/typedef/) { - if (/.*\(\*(\w+)\)\(/) { - $title = "typedef:$1" . "[$title]"; - } elsif (/typedef.*\s(\w+);/) { - $title = "typedef:$1" . "[$title]"; - } - $idpath = ""; - } else { - if (/.*[\s*](\w+)\(/) { - $title = "func:$1" . "[$title]"; - $idpath = ""; - } elsif (/.*\(\*(\w+)\)\(/) { - $body = "#newline#" . $title if not $body; - $title = "id:[$idpath$1]::"; - $indent = "\t"; - } elsif (/[^=]*[\s*](\w+)[\[\s,:;]/) { - $body = "#newline#" . $title if not $body; - $title = "id:[$idpath$1]::"; - $indent = "\t"; - } - } + } elsif (/[^=]*[\s*](\w+)[\[\s,:;]/) { + $body = "#newline#" . $title if not $body; + $title = "id:[$idpath$1]::"; + $indent = "\t"; } put_section if $orig_title ne $title; next;