From: Nishi Date: Mon, 30 Sep 2024 15:18:45 +0000 (+0000) Subject: fix some stuff X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3249e4759fc065da3c572c4dc8b9f92e369a3c80;p=docgen.git fix some stuff git-svn-id: file:///raid/svn-personal/docgen/trunk@8 44bc13e5-44cb-984e-b856-1907bf1ada44 --- diff --git a/Makefile b/Makefile index 0df5a92..6919a85 100644 --- a/Makefile +++ b/Makefile @@ -6,3 +6,4 @@ PREFIX=/usr/local install: cp docgen $(PREFIX)/bin/ + chmod +x $(PREFIX)/bin/docgen diff --git a/docgen b/docgen index 433e33e..8d179dd 100755 --- a/docgen +++ b/docgen @@ -107,10 +107,10 @@ proc end_html {fid} { } proc parse_markdown {path _result} { - global title icon + global icon upvar $_result result - set result(title) "$title" + set result(title) "" set result(body) "" set result(toc) "" set result(genre) "" @@ -183,7 +183,7 @@ proc parse_markdown {path _result} { set result(genre) "$genre" } elseif { [regexp -- {^(.+)$} "[regsub {^(#+) } "$line" {}]" -> pagetitle] } { } - set result(title) "$pagetitle - $title" + set result(title) "$pagetitle" set name "$pagetitle" } else { if { $has_h2 == 0 } { @@ -213,7 +213,7 @@ proc parse_markdown {path _result} { } proc rescan {path dots} { - global output_directory input_directory icon genre_list + global output_directory input_directory icon genre_list title foreach name [glob -tails -nocomplain -directory "$input_directory/$path" *] { if { [file type "$input_directory/$path/$name"] == "directory" } { file mkdir "$output_directory/$path/$name" @@ -227,18 +227,22 @@ proc rescan {path dots} { parse_markdown "$input_directory/$path/$name" result set esc "[regsub -all { } "$result(genre)" _]" - set name "genre_$esc" - global $name + set gname "genre_$esc" + global $gname if { [lsearch $genre_list "$esc"] == -1 } { lappend genre_list "$esc" } - lappend "$name" "$path" "$result(title)"; + if { "[file rootname "[file tail "$name"]"]" == "index" } { + lappend "$gname" "$path" "$result(title)"; + } else { + lappend "$gname" "$path/[file rootname "[file tail "$name"]"].html" "$result(title)"; + } - set outfid [open "$output_directory/$path/index.html" "w"] + set outfid [open "$output_directory/$path/[file rootname "[file tail "$name"]"].html" "w"] if { "$icon" != "" } { set result(toc) "\"logo\"
$result(toc)" } - start_html $outfid "$result(title)" "$result(toc)" "$dots" + start_html $outfid "$result(title) - $title" "$result(toc)" "$dots" puts $outfid "$result(body)" end_html $outfid close $outfid @@ -352,11 +356,19 @@ close $fid set outfid [open "$output_directory/index.html" "w"] start_html $outfid "$title" "" "./" puts $outfid "

$title Documentation

" -foreach genre $genre_list { - set name "genre_$genre" - puts $outfid "

[regsub -all {_} "$genre" " "]

" +if { [info exists genre_] } { + set name "genre_" foreach {k v} [set $name] { puts $outfid "$v
" + } +} +foreach genre $genre_list { + set name "genre_$genre" + if { "$name" != "genre_" } { + puts $outfid "

[regsub -all {_} "$genre" " "]

" + foreach {k v} [set $name] { + puts $outfid "$v
" + } } } end_html $outfid diff --git a/example/input/test/index.md b/example/input/test/index.md new file mode 100644 index 0000000..1469fad --- /dev/null +++ b/example/input/test/index.md @@ -0,0 +1 @@ +# Test article diff --git a/example/input/test/test.md b/example/input/test/test.md new file mode 100644 index 0000000..f7b1c22 --- /dev/null +++ b/example/input/test/test.md @@ -0,0 +1 @@ +# Test 2