Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
howto-cards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marie Fossepre
howto-cards
Commits
f4a14b92
Verified
Commit
f4a14b92
authored
3 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
WIP: generate index script
parent
3bebbfd8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.ci/generateIndex.py
+41
-4
41 additions, 4 deletions
.ci/generateIndex.py
with
41 additions
and
4 deletions
.ci/generateIndex.py
+
41
−
4
View file @
f4a14b92
...
@@ -148,7 +148,10 @@ index += '\n<div class="index-box-container">\n'
...
@@ -148,7 +148,10 @@ index += '\n<div class="index-box-container">\n'
whiteList
=
''
whiteList
=
''
localIndexArr
=
[[]]
*
len
(
sections
)
localIndexArr
=
[[]]
*
len
(
sections
)
orderArr
=
[[]]
*
len
(
sections
)
for
folder
in
cardDirs
:
for
folder
in
cardDirs
:
# FolderFlag gets set to true at the first iteration
folderFlag
=
True
# check if folder exists
# check if folder exists
if
path
.
isdir
(
folder
):
if
path
.
isdir
(
folder
):
...
@@ -163,12 +166,12 @@ for folder in cardDirs:
...
@@ -163,12 +166,12 @@ for folder in cardDirs:
# get the index of the section
# get the index of the section
indexS
=
sections
.
index
(
d
)
indexS
=
sections
.
index
(
d
)
maxOrder
=
0
#print(indexS)
#print(indexS)
if
len
(
localIndexArr
[
indexS
])
==
0
:
if
len
(
localIndexArr
[
indexS
])
==
0
:
localIndexArr
[
indexS
]
=
[
"
\n
"
]
localIndexArr
[
indexS
]
=
[
"
\n
"
]
orderArr
=
[]
# walk through the folders with all the cards
# walk through the folders with all the cards
for
root
,
dirs
,
files
in
os
.
walk
(
folder
+
"
/
"
+
d
):
for
root
,
dirs
,
files
in
os
.
walk
(
folder
+
"
/
"
+
d
):
for
file
in
files
:
for
file
in
files
:
...
@@ -200,9 +203,38 @@ for folder in cardDirs:
...
@@ -200,9 +203,38 @@ for folder in cardDirs:
# define the header for each card
# define the header for each card
header
=
"
---
\n
"
header
=
"
---
\n
"
print
(
orderArr
)
if
len
(
order
)
>
0
:
if
len
(
order
)
>
0
:
header
+=
"
order:
"
+
str
(
order
)
+
"
\n
"
header
+=
"
order:
"
+
str
(
order
)
+
"
\n
"
orderArr
.
append
(
int
(
order
))
# append the order of the card
# find the maximum of existing orders
if
folderFlag
:
if
len
(
orderArr
[
indexS
])
>
0
:
maxOrder
=
max
(
orderArr
[
indexS
])
else
:
maxOrder
=
0
# after determining the max order, set the folder flag to False to avoid another entry into the same block of code
folderFlag
=
False
tmp
=
orderArr
[
indexS
]
print
(
"
tmp
"
)
print
(
tmp
)
tmp
.
append
(
maxOrder
+
int
(
order
))
orderArr
[
indexS
]
=
tmp
print
(
tmp
)
else
:
orderArr
[
indexS
]
=
[]
print
(
orderArr
)
print
(
"
maxOrder:
"
+
str
(
maxOrder
))
print
(
"
folderFlag:
"
+
str
(
folderFlag
))
print
(
"
indexS:
"
+
str
(
indexS
))
header
+=
"
layout: page
\n
"
header
+=
"
layout: page
\n
"
header
+=
"
permalink:
"
+
permalink
+
"
\n
"
header
+=
"
permalink:
"
+
permalink
+
"
\n
"
header
+=
"
shortcut:
"
+
root_handbook
(
shortcut
)
+
"
\n
"
header
+=
"
shortcut:
"
+
root_handbook
(
shortcut
)
+
"
\n
"
...
@@ -259,10 +291,15 @@ for folder in cardDirs:
...
@@ -259,10 +291,15 @@ for folder in cardDirs:
print
(
"
+ New header added.
"
)
print
(
"
+ New header added.
"
)
print
(
"
-----------------------
"
)
print
(
"
-----------------------
"
)
if
len
(
orderArr
)
>
0
:
if
len
(
orderArr
[
indexS
])
>
0
:
print
(
"
here
"
)
print
(
localIndexArr
[
indexS
])
print
(
orderArr
[
indexS
])
X
=
localIndexArr
[
indexS
][
1
:]
X
=
localIndexArr
[
indexS
][
1
:]
Y
=
orderArr
Y
=
orderArr
[
indexS
]
localIndexArr
[
indexS
]
=
[
x
for
_
,
x
in
sorted
(
zip
(
Y
,
X
))]
localIndexArr
[
indexS
]
=
[
x
for
_
,
x
in
sorted
(
zip
(
Y
,
X
))]
print
(
localIndexArr
[
indexS
])
else
:
else
:
# join all subcategories to the index
# join all subcategories to the index
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment