Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hpc-compendium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZIH
hpcsupport
hpc-compendium
Merge requests
!780
Make TOC and page heading match
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Make TOC and page heading match
issue-454
into
preview
Overview
12
Commits
22
Pipelines
0
Changes
1
Merged
Martin Schroschk
requested to merge
issue-454
into
preview
2 years ago
Overview
12
Commits
22
Pipelines
0
Changes
1
Expand
Resolve
#454 (closed)
0
0
Merge request reports
Viewing commit
4c07c7e7
Prev
Next
Show latest version
1 file
+
44
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
4c07c7e7
Add a script for auto-filtering different TOC entries and page headings
· 4c07c7e7
Taras Lazariv
authored
2 years ago
doc.zih.tu-dresden.de/util/check-TOC-equals-page-headings.py
0 → 100644
+
44
−
0
Options
"""
Check for consistency between TOC and page headings.
Provide as an command line argument the path to the mkdocs.yml file.
Author: Taras Lazariv
"""
import
os
import
sys
import
yaml
import
pandas
as
pd
def
list_and_read_files
(
path
):
"
List files in a directory recursively and read the first line of each file
"
files
=
[]
firstline
=
[]
for
root
,
_
,
filenames
in
os
.
walk
(
path
):
for
filename
in
filenames
:
if
filename
.
endswith
(
'
.md
'
):
files
.
append
(
os
.
path
.
join
(
root
.
split
(
'
/
'
)[
-
1
],
filename
))
firstline
.
append
(
open
(
os
.
path
.
join
(
root
,
filename
)).
readline
().
strip
().
replace
(
'
#
'
,
''
))
df
=
pd
.
DataFrame
({
'
file
'
:
files
,
'
firstline
'
:
firstline
})
return
df
def
main
():
"
Main function
"
path
=
os
.
getcwd
()
df
=
list_and_read_files
(
path
)
nav_section
=
dict
()
with
open
(
sys
.
argv
[
1
],
'
r
'
)
as
file
:
for
line
in
file
:
line
=
line
.
rstrip
()
if
line
.
endswith
(
'
.md
'
):
nav_section
.
update
(
yaml
.
safe_load
(
line
)[
0
])
nav_df
=
pd
.
DataFrame
(
nav_section
.
items
(),
columns
=
[
'
title
'
,
'
file
'
])
with
pd
.
option_context
(
'
display.max_rows
'
,
None
):
# more options can be specified also
complete_nav_df
=
pd
.
merge
(
df
,
nav_df
,
on
=
'
file
'
,
how
=
'
outer
'
)
print
(
complete_nav_df
.
loc
[
~
(
complete_nav_df
[
'
firstline
'
]
==
complete_nav_df
[
'
title
'
])])
if
__name__
==
'
__main__
'
:
main
()
\ No newline at end of file
Loading