Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
howto-cards LEGACY VERSION
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
R3
howto-cards LEGACY VERSION
Commits
d4008f36
Verified
Commit
d4008f36
authored
3 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
add draft to base index generation on a given order
parent
09047b55
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!350
[release] Regular merge of develop
,
!349
Draft: [release] Regular merge of develop
,
!331
ordering of cards
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.ci/generateIndex.py
+38
-4
38 additions, 4 deletions
.ci/generateIndex.py
with
38 additions
and
4 deletions
.ci/generateIndex.py
+
38
−
4
View file @
d4008f36
...
...
@@ -42,6 +42,23 @@ def build_section_start(title, shortcut):
def
build_section_end
():
return
"
\t\t
</ul>
\n\t
</div>
"
def
save_order
(
localroot
,
root
,
filename
):
order
=
""
os
.
chdir
(
root
)
with
open
(
filename
,
'
r
'
)
as
f
:
for
line
in
f
:
# check for the start of the section
#print(line)
if
line
[
0
:
6
]
==
"
order:
"
:
order
=
line
[
7
:]
break
# change back to the local root
os
.
chdir
(
localroot
)
return
order
.
rstrip
()
def
save_legacy_from
(
localroot
,
root
,
filename
):
legacy_from
=
[]
os
.
chdir
(
root
)
...
...
@@ -56,12 +73,13 @@ def save_legacy_from(localroot, root, filename):
legacy_from_flag
=
True
# append lines from the legacy section
if
legacy_from_flag
and
line
[
0
:
12
]
:
if
legacy_from_flag
:
legacy_from
.
append
(
line
)
# check for the end of the header
if
legacy_from_flag
and
line
[
0
:
3
]
==
"
---
"
:
legacy_from_flag
=
False
break
# change back to the local root
os
.
chdir
(
localroot
)
...
...
@@ -75,6 +93,7 @@ def remove_header(localroot, root, filename):
# count the number of lines
count
=
0
n
=
0
headerCheck
=
False
with
open
(
filename
,
'
r
'
)
as
f
:
for
line
in
f
:
...
...
@@ -149,6 +168,7 @@ for folder in cardDirs:
if
len
(
localIndexArr
[
indexS
])
==
0
:
localIndexArr
[
indexS
]
=
[
"
\n
"
]
orderArr
=
[]
# walk through the folders with all the cards
for
root
,
dirs
,
files
in
os
.
walk
(
folder
+
"
/
"
+
d
):
for
file
in
files
:
...
...
@@ -159,7 +179,8 @@ for folder in cardDirs:
if
file
[
0
]
!=
"
_
"
:
print
(
"
> Generating header for:
"
+
fileName
)
# save legacy section
# save order and legacy section
order
=
save_order
(
localroot
,
root
,
file
)
legacy_from
=
save_legacy_from
(
localroot
,
root
,
file
)
# remove the previous header
...
...
@@ -179,6 +200,9 @@ for folder in cardDirs:
# define the header for each card
header
=
"
---
\n
"
if
len
(
order
)
>
0
:
header
+=
"
order:
"
+
str
(
order
)
+
"
\n
"
orderArr
.
append
(
int
(
order
))
header
+=
"
layout: page
\n
"
header
+=
"
permalink:
"
+
permalink
+
"
\n
"
header
+=
"
shortcut:
"
+
root_handbook
(
shortcut
)
+
"
\n
"
...
...
@@ -235,8 +259,18 @@ for folder in cardDirs:
print
(
"
+ New header added.
"
)
print
(
"
-----------------------
"
)
# join all subcategories to the index
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
print
(
localIndexArr
[
indexS
])
print
(
orderArr
)
if
len
(
orderArr
)
>
0
:
Y
=
orderArr
X
=
localIndexArr
[
indexS
][
1
:]
print
(
"
here
"
)
localIndexArr
[
indexS
]
=
[
x
for
_
,
x
in
sorted
(
zip
(
Y
,
X
))]
print
(
localIndexArr
[
indexS
])
else
:
# join all subcategories to the index
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
print
(
localIndexArr
)
...
...
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