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
dece49eb
Verified
Commit
dece49eb
authored
3 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
draft: ordering of sections
parent
c38fe30e
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
+67
-16
67 additions, 16 deletions
.ci/generateIndex.py
with
67 additions
and
16 deletions
.ci/generateIndex.py
+
67
−
16
View file @
dece49eb
...
@@ -161,8 +161,8 @@ index = ''
...
@@ -161,8 +161,8 @@ index = ''
index
+=
'
\n
<div class=
"
index-box-container
"
>
\n
'
index
+=
'
\n
<div class=
"
index-box-container
"
>
\n
'
whiteList
=
''
whiteList
=
''
localIndexArr
=
[[]]
*
len
(
sections
)
localIndexArr
=
{
k
:
[]
for
k
in
range
(
len
(
sections
)
)}
orderArr
=
[[]]
*
len
(
sections
)
orderArr
=
{
k
:
[]
for
k
in
range
(
len
(
sections
)
)}
for
folder
in
cardDirs
:
for
folder
in
cardDirs
:
# FolderFlag gets set to true at the first iteration
# FolderFlag gets set to true at the first iteration
...
@@ -182,9 +182,6 @@ for folder in cardDirs:
...
@@ -182,9 +182,6 @@ for folder in cardDirs:
indexS
=
sections
.
index
(
d
)
indexS
=
sections
.
index
(
d
)
maxOrder
=
0
maxOrder
=
0
# reset the ordering array per section
orderArr
[
indexS
]
=
[]
if
len
(
localIndexArr
[
indexS
])
==
0
:
if
len
(
localIndexArr
[
indexS
])
==
0
:
localIndexArr
[
indexS
]
=
[
"
\n
"
]
localIndexArr
[
indexS
]
=
[
"
\n
"
]
...
@@ -220,6 +217,9 @@ for folder in cardDirs:
...
@@ -220,6 +217,9 @@ for folder in cardDirs:
# define the header for each card
# define the header for each card
header
=
"
---
\n
"
header
=
"
---
\n
"
#print("orderArr --- ")
#print(orderArr)
if
len
(
order
)
>
0
:
if
len
(
order
)
>
0
:
header
+=
"
order:
"
+
str
(
order
)
+
"
\n
"
header
+=
"
order:
"
+
str
(
order
)
+
"
\n
"
# append the order of the card
# append the order of the card
...
@@ -233,12 +233,26 @@ for folder in cardDirs:
...
@@ -233,12 +233,26 @@ for folder in cardDirs:
# after determining the max order, set the folder flag to False to avoid another entry into the same block of code
# after determining the max order, set the folder flag to False to avoid another entry into the same block of code
folderFlag
=
False
folderFlag
=
False
tmp
=
orderArr
[
indexS
]
tmp
=
orderArr
[
indexS
]
.
copy
()
tmp
.
append
(
maxOrder
+
int
(
order
))
tmp
.
append
(
maxOrder
+
int
(
order
))
#print("tmp --- ")
#print(tmp)
#print("")
#print("indexS")
#print(indexS)
#print("orderArr --- ")
#print(orderArr)
#print("orderArr[indexS] --- ")
#print(orderArr[indexS])
orderArr
[
indexS
]
=
tmp
orderArr
[
indexS
]
=
tmp
#print("orderArr --- ")
#print(orderArr)
else
:
else
:
orderArr
[
indexS
]
=
[]
orderArr
[
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
"
...
@@ -294,18 +308,55 @@ for folder in cardDirs:
...
@@ -294,18 +308,55 @@ for folder in cardDirs:
# output
# output
print
(
"
+ New header added.
"
)
print
(
"
+ New header added.
"
)
print
(
"
-----------------------
"
)
print
(
"
-----------------------
"
)
#print("")
# join all subcategories to the index
# if all subcategories have a predefined order
if
len
(
orderArr
[
indexS
])
<=
len
(
localIndexArr
[
indexS
])
and
len
(
orderArr
[
indexS
])
>
0
:
#debugging
X
=
localIndexArr
[
indexS
][
1
:]
#print("--- debugging ---")
Y
=
orderArr
[
indexS
]
#print(indexS)
localIndexArr
[
indexS
]
=
[
x
for
_
,
x
in
sorted
(
zip
(
Y
,
X
))]
#print("---")
# natural sorting otherwise
#print(localIndexArr[indexS])
else
:
#print("---")
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
#print(orderArr)
#print("")
# ordering of cards
#print("-- sorting --")
for
d
in
sections
:
#print("section: " + d)
indexS
=
sections
.
index
(
d
)
#print(indexS)
#print("")
#print("-- order --")
#print(orderArr[indexS])
#print("-- before ordering --")
#print(localIndexArr[indexS])
#print("")
#print(len(orderArr[indexS]))
#print(len(localIndexArr[indexS]))
# join all subcategories to the index
# if all subcategories have a predefined order
if
len
(
orderArr
[
indexS
])
==
len
(
localIndexArr
[
indexS
])
-
1
and
len
(
orderArr
[
indexS
])
>
0
:
print
(
""
)
X
=
localIndexArr
[
indexS
][
1
:]
Y
=
orderArr
[
indexS
]
#print("-- X --")
#print(X)
#print("-- Y --")
#print(Y)
localIndexArr
[
indexS
]
=
[
x
for
_
,
x
in
sorted
(
zip
(
Y
,
X
))]
# natural sorting otherwise
else
:
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
#print("-- after ordering --")
#print(localIndexArr[indexS])
#print("")
print
(
localIndexArr
)
print
(
localIndexArr
)
#print(sections)
# determine the index
# determine the index
k
=
0
k
=
0
...
...
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