-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddAllReadmes.tcl
More file actions
executable file
·121 lines (113 loc) · 3.8 KB
/
AddAllReadmes.tcl
File metadata and controls
executable file
·121 lines (113 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/tclsh
#*****************************************************************************
#
# System :
# Module :
# Object Name : $RCSfile$
# Revision : $Revision$
# Date : $Date$
# Author : $Author$
# Created By : Robert Heller
# Created : Wed Apr 28 10:13:03 2021
# Last Modified : <210429.1138>
#
# Description
#
# Notes
#
# History
#
#*****************************************************************************
#
# Copyright (C) 2021 Robert Heller D/B/A Deepwoods Software
# 51 Locke Hill Road
# Wendell, MA 01379-9728
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
#*****************************************************************************
package require snit
snit::type AddAllReadmes {
pragma -hastypeinfo no
pragma -hastypedestroy no
pragma -hasinstances no
typevariable _ExceptDirs {Adafruit-METRO-328-PCB hats-master
KiCad-Schematic-Symbol-Libraries max7219-master RPi_Hat.pretty
RPi_Hat_Template CommonOpenMRNExtras ABSWithSiding SMCSenseHAT-EEProm}
typevariable _Subdir {}
typemethod SetSubdir {dir} {
if {$dir eq ""} {
set _Subdir {}
} else {
set _Subdir "$dir/"
}
}
typevariable LinkFormat {1. [%s](https://github.com/RobertPHeller/RPi-RRCircuits/tree/master/%s%s)}
proc generateOneLink {dirname} {
puts stdout [format $LinkFormat $dirname $_Subdir $dirname]
}
proc blockquoteP1 {readmefile} {
set fp [open $readmefile r]
gets $fp line
puts stdout {}
while {[gets $fp line] >= 0} {
if {[string trim $line] ne ""} {break}
}
puts stdout " > $line"
while {[gets $fp line] >= 0} {
if {[string trim $line] eq ""} {break}
puts stdout " > $line"
}
close $fp
}
typevariable _HeaderPattern {^## Availble Projects:}
typemethod SetHeader {header} {
set _HeaderPattern "^$header"
}
typevariable _SkipPattern1 {^1. \[[^\]]}
typevariable _SkipPattern2 {^[[:space:]]{4}>[[:space:]]}
typemethod Main {} {
set header [from ::argv -header {## Availble Projects:}]
$type SetHeader $header
set subdir [from ::argv -subdir {}]
$type SetSubdir $subdir
while {[gets stdin line] >= 0} {
puts stdout $line
if {[regexp $_HeaderPattern $line] > 0} {
break
}
}
while {[gets stdin line] >= 0} {
if {[string trim $line] eq ""} {continue}
if {[regexp $_SkipPattern1 $line] > 0} {continue}
if {[regexp $_SkipPattern2 $line] > 0} {continue}
break
}
foreach d [lsort -dictionary [glob -nocomplain "*/README.md"]] {
set dirname [file tail [file dirname $d]]
if {[lsearch -exact $_ExceptDirs $dirname] >= 0} {continue}
puts stdout ""
generateOneLink $dirname
blockquoteP1 $d
}
puts stdout ""
while {[gets stdin line] >= 0} {
puts stdout $line
}
}
}
AddAllReadmes Main