]> Git repositories of Nishi - docgen.git/commitdiff
fix some stuff
authorNishi <nishi@nishi.boats>
Mon, 30 Sep 2024 15:18:45 +0000 (15:18 +0000)
committerNishi <nishi@nishi.boats>
Mon, 30 Sep 2024 15:18:45 +0000 (15:18 +0000)
git-svn-id: file:///raid/svn-personal/docgen/trunk@8 44bc13e5-44cb-984e-b856-1907bf1ada44

Makefile
docgen
example/input/test/index.md [new file with mode: 0644]
example/input/test/test.md [new file with mode: 0644]

index 0df5a9265480abd1c30c2aa01b604146709b6f56..6919a85af62f1fe3b6b64461dc3fbfc73ea931b7 100644 (file)
--- 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 433e33e308a21d9b5224e562ef01b5d9d4012b7a..8d179dd2d24566db52f37a067091243cb0c08904 100755 (executable)
--- 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) "<a href=\"$dots\"><img src=\"$dots/[file tail "$icon"]\" alt=\"logo\"></a><br>$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 "<h1>$title Documentation</h1>"
-foreach genre $genre_list {
-       set name "genre_$genre"
-       puts $outfid "<h3>[regsub -all {_} "$genre" " "]</h3>"
+if { [info exists genre_] } {
+       set name "genre_"
        foreach {k v} [set $name] {
                puts $outfid "<a href=\".$k\">$v</a><br>"
+       }               
+}
+foreach genre $genre_list {
+       set name "genre_$genre"
+       if { "$name" != "genre_" } {
+               puts $outfid "<h3>[regsub -all {_} "$genre" " "]</h3>"
+               foreach {k v} [set $name] {
+                       puts $outfid "<a href=\".$k\">$v</a><br>"
+               }
        }
 }
 end_html $outfid
diff --git a/example/input/test/index.md b/example/input/test/index.md
new file mode 100644 (file)
index 0000000..1469fad
--- /dev/null
@@ -0,0 +1 @@
+# Test article
diff --git a/example/input/test/test.md b/example/input/test/test.md
new file mode 100644 (file)
index 0000000..f7b1c22
--- /dev/null
@@ -0,0 +1 @@
+# Test 2