FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
frontend/docs/generate-toc.sh at master · devhttps/frontend · GitHub
devhttps
/
frontend
Public
forked from
guardian/frontend
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
frontend
/
docs
/
generate-toc.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
58 lines (50 loc) · 1.15 KB
Breadcrumbs
frontend
/
docs
/
generate-toc.sh
Copy path
File metadata and controls
executable file
·
58 lines (50 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!
/bin/bash
cleanDirectoryName
() {
#
Remove leading number
#
Replace dash with space
#
Remove trailing '/'
#
trim spaces
dirname=
$(
echo
"
$1
"
\
|
sed
'
s/^[0-9]*//g
'
\
|
sed
'
s/-/ /g
'
\
|
sed
'
s/\/$//g
'
\
|
xargs
)
capitalize
"
$dirname
"
}
cleanFileTitle
() {
#
Get title
#
Remove formatting markdown characters
#
Also trim spaces
head -n 1
"
$1
"
|
sed
'
s/[*#]//g
'
|
xargs
}
capitalize
() {
#
Capitalize first letter
head=
$(
echo
"
$1
"
|
cut -c1
|
tr [a-z] [A-Z]
)
tail=
$(
echo
"
$1
"
|
cut -c2-
)
echo
"
$head$tail
"
}
root=
$(
git rev-parse --show-toplevel
)
docs=
"
$root
/docs
"
pushd
$docs
>
/dev/null
echo
"
# Table Of Contents
"
echo
"
*(Do NOT edit manually. Generated automatically)*
"
echo
"
"
for
dir
in
*
/
;
do
dirname=
$(
cleanDirectoryName
$dir
)
echo
"
## [
$dirname
](
$dir
)
"
cd
$dir
>
/dev/null
for
doc
in
*
.md
;
do
if
[
"
$doc
"
!=
"
README.md
"
]
;
then
filepath=
$dir$doc
title=
$(
cleanFileTitle
$doc
)
echo
"
- [
$title
](
$filepath
)
"
fi
done
cd
..
echo
"
"
done
echo
"
"
echo
"
---
"
cat how-to-create-a-doc-file.md
echo
"
"
popd
>
/dev/null
Back
|
FazBrowse Home
|
New Git URL