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
fdf3f15e
Verified
Commit
fdf3f15e
authored
2 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
remove part from core
parent
74060611
No related branches found
No related tags found
2 merge requests
!411
[release] Regular merge of develop
,
!404
add generator
Pipeline
#61992
failed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.ci/generateIndex.py
+6
-79
6 additions, 79 deletions
.ci/generateIndex.py
with
6 additions
and
79 deletions
.ci/generateIndex.py
+
6
−
79
View file @
fdf3f15e
from
natsort
import
natsorted
from
pathlib
import
Path
from
generator.library
import
*
# loop through the entire internal tree
localroot
=
os
.
getcwd
()
# retrieve ignore list
ignore
=
get_ignore
()
# generate the index properly speaking
cardDirs
=
[
"
internal
"
,
"
external
"
]
sections
=
[]
# determine first the directories
for
direct
in
cardDirs
:
if
path
.
isdir
(
direct
)
and
has_subdirs
(
direct
):
dirs
=
os
.
listdir
(
direct
)
dirs
=
natsorted
(
dirs
)
for
d
in
dirs
:
if
d
[
0
]
!=
"
.
"
and
d
not
in
ignore
and
has_subdirs
(
direct
+
"
/
"
+
d
):
sections
.
append
(
d
)
sections
=
list
(
s
et
(
sections
)
)
sections
=
natsorted
(
sections
)
sections
,
ignore
=
g
et
_
sections
(
cardDirs
)
localIndexArr
,
orderArr
=
get_indexArr
(
sections
)
# Index contains the generated content, init it with an empty container
index
=
''
index
+=
'
\n
<div class=
"
index-box-container
"
>
\n
'
whiteList
=
''
localIndexArr
=
{
k
:
[]
for
k
in
range
(
len
(
sections
))}
orderArr
=
{
k
:
[]
for
k
in
range
(
len
(
sections
))}
for
folder
in
cardDirs
:
# FolderFlag gets set to true at the first iteration
folderFlag
=
True
...
...
@@ -54,66 +36,11 @@ for folder in cardDirs:
# walk through the folders with all the cards
for
root
,
dirs
,
files
in
os
.
walk
(
folder
+
"
/
"
+
d
):
for
file
in
files
:
if
file
.
endswith
(
"
.md
"
):
fileName
=
os
.
path
.
join
(
root
,
file
)
folderFlag
,
localIndexArr
,
whiteList
=
core
(
file
,
fileName
,
localroot
,
root
,
folder
,
localIndexArr
,
orderArr
,
indexS
,
whiteList
,
folderFlag
,
maxOrder
)
# ordering of cards
for
d
in
sections
:
indexS
=
sections
.
index
(
d
)
# 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
]
localIndexArr
[
indexS
]
=
[
x
for
_
,
x
in
sorted
(
zip
(
Y
,
X
))]
# natural sorting otherwise
else
:
localIndexArr
[
indexS
]
=
natsorted
(
localIndexArr
[
indexS
])
print
(
localIndexArr
)
# determine the index
k
=
0
for
s
in
sections
:
index
+=
build_section_start
(
s
.
replace
(
"
-
"
,
"
"
).
capitalize
(),
s
)
index
+=
''
.
join
(
localIndexArr
[
k
])
index
+=
build_section_end
()
k
+=
1
# close the container
index
+=
"
\n
</div>
"
## add link to return to main index
index
+=
"""
<br><center><a href=
"
{{
'
/
'
| relative_url }}
"
>go back</a></center>
"""
index
+=
"""
<br><center><a href=
"
{{
'
/cards
'
| relative_url }}
"
>Overview of all HowTo cards</a></center>
"""
# output the index
#print(index)
# Read in the file
indexFile
=
"
cards.md
"
filedata
=
""
with
open
(
indexFile
,
'
r
'
)
as
file
:
for
line
in
file
:
filedata
+=
line
# stop reading once the index place holder has been reached
if
re
.
search
(
"
<!-- index -->
"
,
line
):
filedata
+=
"
[[ index ]]
"
break
# Replace the target string
filedata
=
filedata
.
replace
(
'
[[ index ]]
'
,
index
)
# Write the file out again
with
open
(
indexFile
,
'
w
'
)
as
file
:
file
.
write
(
filedata
)
folderFlag
,
localIndexArr
,
whiteList
=
core
(
file
,
localroot
,
root
,
folder
,
localIndexArr
,
orderArr
,
indexS
,
whiteList
,
folderFlag
,
maxOrder
)
print
(
"
\n
> New index generated and saved in
"
+
indexFile
)
localIndexArr
=
sort_sections
(
sections
,
localIndexArr
,
orderArr
)
index
=
generate_index
(
index
,
sections
,
localIndexArr
)
save_index
(
index
,
"
cards.md
"
)
# write link whitelist out
whiteListFile
=
"
.ci/whitelist.txt
"
...
...
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