From: Alan T. DeKok Date: Thu, 22 Aug 2019 17:25:31 +0000 (-0400) Subject: print module config at the end of the file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e0f0b6151d79b3be758f568c19c7eb741488c0a;p=thirdparty%2Ffreeradius-server.git print module config at the end of the file instead of in-line, which can get confusing The behavior can be toggle via `-t`, which is nice --- diff --git a/doc/all.mk b/doc/all.mk index b66366f97aa..70186ba761a 100644 --- a/doc/all.mk +++ b/doc/all.mk @@ -188,7 +188,7 @@ doc/raddb/%.adoc: raddb/% @echo ADOC $^ ${Q}mkdir -p $(dir $@) ${Q}perl -pi -e 's/^# ([^ \t])/# $$1/;s/^([ \t]+)# ([^ \t])/$$1# $$2/;s/[ \t]+$$//' $^ - ${Q}./scripts/asciidoc/conf2adoc -a ${top_srcdir}/asciidoc -o $@ < $^ + ${Q}./scripts/asciidoc/conf2adoc -t -a ${top_srcdir}/asciidoc -o $@ < $^ README_MODULES := $(wildcard src/modules/rlm_*/README.md) doc/raddb/mods-available/all_modules.adoc: $(README_MODULES) diff --git a/scripts/asciidoc/conf2adoc b/scripts/asciidoc/conf2adoc index a2388a83036..fb203f90803 100755 --- a/scripts/asciidoc/conf2adoc +++ b/scripts/asciidoc/conf2adoc @@ -14,10 +14,13 @@ $raw = 0; $blank = 0; $print_code = 0; -getopts('a:c:o:'); +getopts('a:c:o:t'); $script_dir = dirname(__FILE__); $filename = "$script_dir/links.txt"; + +$opt_c = 0 if (defined $opt_t) ; + $print_code = $opt_c; %links = {}; @@ -43,6 +46,7 @@ $links{"mods-available/"} = "$opt_a/mods-available/index.adoc"; sub process_file { my $input = shift; my $output_file = shift; + my @code = (); if (!defined $output_file) { $output = STDOUT; @@ -197,7 +201,12 @@ sub process_file { $line =~ s,RFC (\d+),https://tools.ietf.org/html/rfc${1}\[RFC $1\],g; } - next if (!$print_code && $raw && $was_raw); + if (!$print_code) { + if ($raw && $was_raw) { + push @code, $line if ($opt_t); + next; + } + } # # And print out the raw text. @@ -209,6 +218,18 @@ sub process_file { # Terminate any trailing "raw" text. # print $output "```\n" if ($print_code); + + if ($opt_t) { + print $output "== Default Configuration\n\n"; + + print $output "```\n"; + + foreach $line (@code) { + print $output $line; + } + + print $output "```\n"; + } } sub HELP_MESSAGE {