cmdr
Check-in [b5c4809789]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cmdr::help::json, cmdr::help::tcl - Fixed handling of category with sub-categories, but no commands. Bumped to version 1.0.1.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b5c480978951c6709197169d367937029e78b3f3
User & Date: andreask 2014-05-05 18:52:13
Context
2014-05-07
21:58
cmdr::validate (rpath) - Fixed bug in the path check. Removed bogus test for directory. This VT accepts files too. Bumped to version 1.3.1. check-in: e7ed76dd06 user: andreask tags: trunk
2014-05-05
18:52
cmdr::help::json, cmdr::help::tcl - Fixed handling of category with sub-categories, but no commands. Bumped to version 1.0.1. check-in: b5c4809789 user: andreask tags: trunk
2014-04-23
05:39
Move the p-name helper command of validate::common into the parameter class, as a convenience method. check-in: 288c34780b user: aku tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to help_json.tcl.

     1      1   ## -*- tcl -*-
     2      2   # # ## ### ##### ######## ############# #####################
     3      3   ## CMDR - Help - JSON format. Not available by default.
     4      4   ## Require this package before creation a commander, so that the
     5      5   ## mdr::help heuristics see and automatically integrate the format.
     6      6   
     7      7   # @@ Meta Begin
     8         -# Package cmdr::help::json 1.0
            8  +# Package cmdr::help::json 1.0.1
     9      9   # Meta author   {Andreas Kupries}
    10     10   # Meta location https://core.tcl.tk/akupries/cmdr
    11     11   # Meta platform tcl
    12     12   # Meta summary     Formatting help as JSON object.
    13     13   # Meta description Formatting help as JSON object.
    14     14   # Meta subject {command line}
    15     15   # Meta require {Tcl 8.5-}
................................................................................
    81     81   namespace eval ::cmdr::help::format::JSON {}
    82     82   
    83     83   proc ::cmdr::help::format::JSON::acategory {path cmds subc} {
    84     84       set name [lindex $path end]
    85     85   
    86     86       # With struct::list map we could then also re-use alist.
    87     87       set commands {}
    88         -    foreach def [lsort -dict -unique [dict get $cmds $path]] {
    89         -	lassign $def cname _
    90         -	lappend commands [json::write string $cname]
           88  +    if {[dict exists $cmds $path]} {
           89  +	foreach def [lsort -dict -unique [dict get $cmds $path]] {
           90  +	    lassign $def cname _
           91  +	    lappend commands [json::write string $cname]
           92  +	}
    91     93       }
    92     94   
    93     95       set sections {}
    94     96       if {[dict exists $subc $path]} {
    95     97   	# Add the sub-categories, if any.
    96     98   	foreach c [lsort -dict -unique [dict get $subc $path]] {
    97     99   	    lappend sections [acategory [linsert $path end $c] $cmds $subc]
................................................................................
   197    199   proc ::cmdr::help::format::JSON::astring {string} {
   198    200       regsub -all -- {[ \n\t]+} $string { } string
   199    201       return [json::write string [string trim $string]]
   200    202   }
   201    203   
   202    204   # # ## ### ##### ######## ############# #####################
   203    205   ## Ready
   204         -package provide cmdr::help::json 1.0
          206  +package provide cmdr::help::json 1.0.1

Changes to help_tcl.tcl.

     1      1   ## -*- tcl -*-
     2      2   # # ## ### ##### ######## ############# #####################
     3      3   ## CMDR - Help - TCL format. Not available by default.
     4      4   ## Require this package before creation a commander, so that the
     5      5   ## mdr::help heuristics see and automatically integrate the format.
     6      6   
     7      7   # @@ Meta Begin
     8         -# Package cmdr::help::tcl 1.0
            8  +# Package cmdr::help::tcl 1.0.1
     9      9   # Meta author   {Andreas Kupries}
    10     10   # Meta location https://core.tcl.tk/akupries/cmdr
    11     11   # Meta platform tcl
    12     12   # Meta summary     Formatting help as TCL data structure (nested dict/list).
    13     13   # Meta description Formatting help as TCL data structure (nested dict/list).
    14     14   # Meta subject {command line}
    15     15   # Meta require {Tcl 8.5-}
................................................................................
    77     77   namespace eval ::cmdr::help::format::TCL {}
    78     78   
    79     79   proc ::cmdr::help::format::TCL::acategory {path cmds subc} {
    80     80       set name [lindex $path end]
    81     81   
    82     82       # With struct::list map we could then also re-use alist.
    83     83       set commands {}
    84         -    foreach def [lsort -dict -unique [dict get $cmds $path]] {
    85         -	lappend commands [lindex $def 0]
           84  +    if {[dict exists $cmds $path]} {
           85  +	foreach def [lsort -dict -unique [dict get $cmds $path]] {
           86  +	    lappend commands [lindex $def 0]
           87  +	}
    86     88       }
    87     89   
    88     90       set sections {}
    89     91       if {[dict exists $subc $path]} {
    90     92   	# Add the sub-categories, if any.
    91     93   	foreach c [lsort -dict -unique [dict get $subc $path]] {
    92     94   	    lappend sections [acategory [linsert $path end $c] $cmds $subc]
................................................................................
   176    178   proc ::cmdr::help::format::TCL::astring {string} {
   177    179       regsub -all -- {[ \n\t]+} $string { } string
   178    180       return [string trim $string]
   179    181   }
   180    182   
   181    183   # # ## ### ##### ######## ############# #####################
   182    184   ## Ready
   183         -package provide cmdr::help::tcl 1.0
          185  +package provide cmdr::help::tcl 1.0.1