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
c4e6b5e3
Verified
Commit
c4e6b5e3
authored
3 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
save legacy from parts of header
parent
2cfc1de6
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
+37
-8
37 additions, 8 deletions
.ci/generateIndex.py
with
37 additions
and
8 deletions
.ci/generateIndex.py
+
37
−
8
View file @
c4e6b5e3
...
...
@@ -42,16 +42,39 @@ def build_section_start(title, shortcut):
def
build_section_end
():
return
"
\t\t
</ul>
\n\t
</div>
"
def
remove_header
(
localroot
,
root
,
filename
):
nfirstlines
=
[]
def
save_legacy_from
(
localroot
,
root
,
filename
):
legacy_from
=
[]
os
.
chdir
(
root
)
# count the number of lines
count
=
0
headerCheck
=
False
legacy_from_flag
=
False
with
open
(
filename
,
'
r
'
)
as
f
:
for
line
in
f
:
count
+=
1
if
line
[
0
:
12
]
==
"
legacy_from:
"
:
legacy_from_flag
=
True
#legacy_from_line_start = count
#cwd = os.getcwd()
if
legacy_from_flag
and
line
[
0
:
12
]:
legacy_from
.
append
(
line
)
if
legacy_from_flag
and
line
[
0
:
3
]
==
"
---
"
:
#legacy_from_line_end = count
legacy_from_flag
=
False
print
(
legacy_from
)
# change back to the local root
os
.
chdir
(
localroot
)
#print("Local root folder:" + os.getcwd())
return
legacy_from
def
remove_header
(
localroot
,
root
,
filename
):
nfirstlines
=
[]
os
.
chdir
(
root
)
#print("Local folder:" + os.getcwd())
# count the number of lines
count
=
0
...
...
@@ -66,7 +89,7 @@ def remove_header(localroot, root, filename):
n
=
count
# remove the header
if
count
>
n
and
headerCheck
:
if
headerCheck
:
with
open
(
filename
)
as
f
,
open
(
"
tmp
"
+
filename
,
"
w
"
)
as
out
:
for
_
in
range
(
n
):
nfirstlines
.
append
(
next
(
f
))
...
...
@@ -79,7 +102,6 @@ def remove_header(localroot, root, filename):
# change back to the local root
os
.
chdir
(
localroot
)
#print("exit folder:" + os.getcwd())
# loop through the entire internal tree
localroot
=
os
.
getcwd
()
...
...
@@ -138,6 +160,9 @@ for folder in cardDirs:
if
file
[
0
]
!=
"
_
"
:
print
(
"
> Generating header for:
"
+
fileName
)
# save legacy from
legacy_from
=
save_legacy_from
(
localroot
,
root
,
file
)
# remove the previous header
if
"
handbook-annexes
"
in
fileName
or
"
handbook-additional
"
in
fileName
:
remove_header
(
localroot
,
root
,
file
)
...
...
@@ -170,7 +195,11 @@ for folder in cardDirs:
header
+=
"
- /cards/
"
+
root_handbook
(
shortcut
)
+
"
\n
"
header
+=
"
- /
"
+
folder
+
"
/cards/
"
+
root_handbook
(
shortcut
)
+
"
\n
"
header
+=
"
---
"
if
len
(
legacy_from
)
>
0
:
for
item
in
legacy_from
:
header
+=
str
(
item
)
else
:
header
+=
"
---
"
# add autogenerated links to whitelist
whiteList
+=
permalink
+
"
\n
"
...
...
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