summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-11-12 20:33:10 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-11-12 20:33:10 -0500
commit37f5ede187984dac04b0d4c6f86680eebca15ae7 (patch)
tree2bf0f052aa845464aa0d785b5ab6b196f90599a5
parent429a6e1a88d37d61575656bf004325d3257c9c56 (diff)
improve documentation generation
-rw-r--r--.gitignore4
-rwxr-xr-xdoc7
-rwxr-xr-xpkgbuild2mw49
3 files changed, 52 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 860c242..4343646 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,12 @@
*.db.tar.gz
*.files
*.files.tar.gz
+
/pkg/
/src/
*.pkg.tar.*
+
/.var.*
/.tmp.*
+
+/*.mw
diff --git a/doc b/doc
index ce02105..adf0dfd 100755
--- a/doc
+++ b/doc
@@ -4,7 +4,12 @@ SHELL = bash -o pipefail
pkgbuilds = $(sort $(wildcard *.PKGBUILD))
config.mw: .var.pkgbuilds $(patsubst %.PKGBUILD,%.mw,$(pkgbuilds))
- cat $(sort $(filter %.mw,$^)) > $@
+ { \
+ echo '=== infrastructure/management ===' && \
+ cat $(filter-out config-service-%,$(sort $(filter %.mw,$^))) && \
+ echo '=== services ===' && \
+ cat $(filter config-service-%,$(sort $(filter %.mw,$^))) && \
+ :; } > $@
%.mw: %.PKGBUILD ./pkgbuild2mw
< $< ./pkgbuild2mw > $@
diff --git a/pkgbuild2mw b/pkgbuild2mw
index b3a4a30..9ee7bff 100755
--- a/pkgbuild2mw
+++ b/pkgbuild2mw
@@ -24,10 +24,10 @@ class Pass0
end
def is_hd
- not /(.*)[^<]<<\s*([^<]\S+)/.match(@line).nil?
+ not /(.*[^<])<<\s*([^<]\S+)/.match(@line).nil?
end
def section_hd
- m = /(.*)[^<]<<\s*([^<]\S+)/.match(@line)
+ m = /(.*[^<])<<\s*([^<]\S+)/.match(@line)
return if m.nil?
prefix = m[1]
eot = m[2]
@@ -38,6 +38,26 @@ class Pass0
getline
end
getline
+ body = body.gsub(/\\(.)/, '\1')
+ $stdout.puts "\n\n{{hc|#{prefix}|<nowiki>#{body.chomp}</nowiki>}}\n\n"
+ end
+
+ def is_hs
+ not /(.*[^<])<<<\'(.*)/.match(@line).nil?
+ end
+ def section_hs
+ m = /(.*[^<])<<<\'(.*)/.match(@line)
+ return if m.nil?
+ prefix = m[1]
+ body = m[2] + "\n"
+ getline
+ while not @line.end_with? "'\n"
+ body += @line
+ getline
+ end
+ body += @line.sub(/'$/, '')
+ getline
+ body = body.gsub("'\\''", "'")
$stdout.puts "\n\n{{hc|#{prefix}|<nowiki>#{body.chomp}</nowiki>}}\n\n"
end
@@ -52,7 +72,11 @@ class Pass0
$stdout.puts "\n\n{{bc|<nowiki>#{section.chomp}</nowiki>}}\n\n" unless section.gsub("\n", '') == ""
section_hd
section = ""
- elsif @line == "}\n"
+ elsif is_hs
+ $stdout.puts "\n\n{{bc|<nowiki>#{section.chomp}</nowiki>}}\n\n" unless section.gsub("\n", '') == ""
+ section_hs
+ section = ""
+ elsif @line == "postamble\n"
$stdout.puts "\n\n{{bc|<nowiki>#{section.chomp}</nowiki>}}\n\n" unless section.gsub("\n", '') == ""
return
else
@@ -86,7 +110,18 @@ class Pass0
m = /^depends\+?=\((.*)\)/.match(@line)
if not m.nil?
m[1].split(/\s+/).each do |pkg|
- $stdout.puts "p* {{ic|#{pkg}}"
+ $stdout.puts "p* {{ic|#{pkg}}}"
+ end
+ getline
+ next
+ end
+ if @line == "depends+=(\n"
+ getline
+ while @line != ")\n"
+ @line.sub(/#.*/, '').split(/\s+/).find_all{|x|not x.empty?}.each do |pkg|
+ $stdout.puts "p* {{ic|#{pkg}}}"
+ end
+ getline
end
getline
next
@@ -104,7 +139,7 @@ class Pass0
end
def run
- while @line != "package() {\n"
+ while @line != "preamble\n"
getline
end
getline
@@ -117,8 +152,8 @@ end
def pass1
exec('sed', '-r',
- '-e', 's@^\{\{hc\|add-file ([^|]*)\|(.*)\}\}$@f* {{ic|/\1}}: {{ic|\2}}@',
- '-e', 's@^\{\{hc\|add-file ([^|]*)\|@f* {{ic|/\1}}\n&@',
+ '-e', 's@^\{\{hc\|add-file (-\S+ )*([^|]*)\|(.*)\}\}$@f* {{ic|/\2}}: {{ic|\3}}@',
+ '-e', 's@^\{\{hc\|add-file (-\S+ )*([^|]*)\|@f* {{ic|/\2}}\n&@',
:in=>$stdin, :out=>$stdout)
end