Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
docs.it4i.cz
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
SCS
docs.it4i.cz
Commits
b068d483
Commit
b068d483
authored
8 months ago
by
Jan Siwiec
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix' into 'master'
modified: .gitlab-ci.yml See merge request
!475
parents
cafa83eb
838b6e0e
No related branches found
No related tags found
1 merge request
!475
modified: .gitlab-ci.yml
Pipeline
#39793
failed
8 months ago
Stage: test
Stage: build
Stage: deploy
Stage: after_test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+2
-0
2 additions, 0 deletions
.gitlab-ci.yml
.spelling
+1
-1
1 addition, 1 deletion
.spelling
scripts/titlemd.py
+35
-47
35 additions, 47 deletions
scripts/titlemd.py
with
38 additions
and
48 deletions
.gitlab-ci.yml
+
2
−
0
View file @
b068d483
...
@@ -34,9 +34,11 @@ pysafety:
...
@@ -34,9 +34,11 @@ pysafety:
capitalize
:
capitalize
:
stage
:
test
stage
:
test
image
:
it4innovations/docker-mkdocscheck:latest
image
:
it4innovations/docker-mkdocscheck:latest
allow_failure
:
true
before_script
:
before_script
:
-
source /opt/.venv3/bin/activate
-
source /opt/.venv3/bin/activate
-
python -V
# debug
-
python -V
# debug
-
pip list | grep titlecase
script
:
script
:
-
find mkdocs.yml docs.it4i/ \( -name '*.md' -o -name '*.yml' \) -print0 | xargs -0 -n1 scripts/titlemd.py --test
-
find mkdocs.yml docs.it4i/ \( -name '*.md' -o -name '*.yml' \) -print0 | xargs -0 -n1 scripts/titlemd.py --test
...
...
This diff is collapsed.
Click to expand it.
.spelling
+
1
−
1
View file @
b068d483
...
@@ -835,4 +835,4 @@ it4ifree
...
@@ -835,4 +835,4 @@ it4ifree
it4ifsusage
it4ifsusage
it4iuserfsusage
it4iuserfsusage
it4iprojectfsusage
it4iprojectfsusage
it4imotd
it4imotd
\ No newline at end of file
This diff is collapsed.
Click to expand it.
scripts/titlemd.py
+
35
−
47
View file @
b068d483
#!/usr/bin/env python
2
#!/usr/bin/env python
3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""
titlemd
"""
# pylint: disable=C0301, R1710
from
__future__
import
print_function
"""
titlemd
"""
import
argparse
import
argparse
import
sys
import
sys
...
@@ -14,7 +14,7 @@ except ImportError:
...
@@ -14,7 +14,7 @@ except ImportError:
def
arg_parse
():
def
arg_parse
():
"""
"""
a
rgument parser
A
rgument parser
"""
"""
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"
Titlemd
"
description
=
"
Titlemd
"
...
@@ -30,16 +30,14 @@ def arg_parse():
...
@@ -30,16 +30,14 @@ def arg_parse():
def
mkdocs_available
(
location
):
def
mkdocs_available
(
location
):
"""
Is mkdocs.yml available?
"""
"""
Is mkdocs.yml available?
"""
if
location
.
find
(
"
mkdocs.yml
"
)
!=
-
1
:
return
"
mkdocs.yml
"
in
location
return
True
return
False
def
linestart
(
line
,
disabled
,
test
,
prev_line
=
None
):
def
linestart
(
line
,
disabled
,
test
,
prev_line
=
None
):
"""
linestart
"""
"""
linestart
"""
if
test
:
if
test
:
if
(
line
.
startswith
(
"
``
"
)
or
line
.
startswith
(
"
extra:
"
))
and
not
disabled
:
if
(
line
.
startswith
(
"
``
"
)
or
line
.
startswith
(
"
extra:
"
))
and
not
disabled
:
return
True
return
True
if
(
line
.
startswith
(
"
``
"
)
or
prev_line
.
startswith
(
"
pages:
"
))
and
disabled
:
if
(
line
.
startswith
(
"
``
"
)
or
(
prev_line
and
prev_line
.
startswith
(
"
pages:
"
))
)
and
disabled
:
return
False
return
False
else
:
else
:
if
line
.
startswith
(
"
``
"
)
and
not
disabled
:
if
line
.
startswith
(
"
``
"
)
and
not
disabled
:
...
@@ -51,93 +49,83 @@ def linestart(line, disabled, test, prev_line=None):
...
@@ -51,93 +49,83 @@ def linestart(line, disabled, test, prev_line=None):
def
testdata
(
arg
):
def
testdata
(
arg
):
"""
test
"""
"""
test
"""
# Spelling exceptions
# Spelling exceptions
with
open
(
'
.spelling
'
)
as
fdata
:
with
open
(
'
.spelling
'
,
encoding
=
'
utf-8
'
)
as
fdata
:
spelling
=
fdata
.
readlines
()
spelling
=
fdata
.
readlines
()
# pylint: disable=unused-argument,inconsistent-return-statements
def
abbreviations
(
word
,
**
_
):
def
abbreviations
(
word
,
**
kwargs
):
"""
abbreviations
"""
"""
abbreviations
"""
if
word
+
"
\n
"
in
spelling
:
if
word
+
"
\n
"
in
spelling
:
return
word
return
word
# Open the file and read the lines as a list
# Open the file and read the lines as a list
with
open
(
arg
.
location
)
as
fdata
:
with
open
(
arg
.
location
,
encoding
=
'
utf-8
'
)
as
fdata
:
lines
=
fdata
.
readlines
()
lines
=
fdata
.
readlines
()
# Loop through the list of lines and titlecase
# Loop through the list of lines and titlecase
# any line beginning with '#'.
# any line beginning with '#'.
return_value
=
0
return_value
=
0
prev_line
=
lines
[
0
]
prev_line
=
lines
[
0
]
if
lines
else
""
echo_filename
=
False
echo_filename
=
False
disabled
=
mkdocs_available
(
arg
.
location
)
disabled
=
mkdocs_available
(
arg
.
location
)
for
line
in
lines
:
for
line
in
lines
:
disabled
=
linestart
(
line
,
disabled
,
arg
.
test
,
prev_line
)
disabled
=
linestart
(
line
,
disabled
,
arg
.
test
,
prev_line
)
if
line
.
startswith
(
'
#
'
)
and
not
disabled
and
not
mkdocs_available
(
arg
.
location
):
if
line
.
startswith
(
'
#
'
)
and
not
disabled
and
not
mkdocs_available
(
arg
.
location
):
if
line
!
=
titlecase
(
line
[:
(
line
.
find
(
"
]
"
)
)
],
title_
line
=
titlecase
(
line
[:
line
.
find
(
"
]
"
)],
callback
=
abbreviations
)
+
line
[
line
.
find
(
"
]
"
):]
callback
=
abbreviations
)
+
line
[(
line
.
find
(
"
]
"
)):]
:
if
line
!=
title_line
:
if
return_value
==
0
and
not
echo_filename
:
if
return_value
==
0
and
not
echo_filename
:
print
(
"
%s
"
%
arg
.
location
)
print
(
f
"
{
arg
.
location
}
"
)
echo_filename
=
True
echo_filename
=
True
print
(
"
-
"
+
line
,
end
=
""
)
print
(
f
"
-
{
line
}
"
,
end
=
""
)
print
(
"
+
"
+
titlecase
(
line
[:(
line
.
find
(
"
]
"
))],
print
(
f
"
+
{
title_line
}
"
,
end
=
""
)
callback
=
abbreviations
)
+
line
[(
line
.
find
(
"
]
"
)):],
end
=
""
)
print
()
print
()
return_value
=
1
return_value
=
1
if
(
line
.
startswith
(
'
---
'
)
or
line
.
startswith
(
'
===
'
))
and
not
disabled
:
if
(
line
.
startswith
(
'
---
'
)
or
line
.
startswith
(
'
===
'
))
and
not
disabled
:
if
prev_line
!
=
titlecase
(
prev_line
[:
(
prev_line
.
find
(
"
]
"
)
)
],
title_
prev_line
=
titlecase
(
prev_line
[:
prev_line
.
find
(
"
]
"
)],
callback
=
abbreviations
)
+
prev_line
[
prev_line
.
find
(
"
]
"
):]
callback
=
abbreviations
)
+
prev_line
[(
prev_line
.
find
(
"
]
"
)):]
:
if
prev_line
!=
title_prev_line
:
if
return_value
==
0
and
not
echo_filename
:
if
return_value
==
0
and
not
echo_filename
:
print
(
"
%s
"
%
arg
.
location
)
print
(
f
"
{
arg
.
location
}
"
)
echo_filename
=
True
echo_filename
=
True
print
(
"
-
"
+
prev_line
,
end
=
""
)
print
(
f
"
-
{
prev_line
}
"
,
end
=
""
)
print
(
"
+
"
+
titlecase
(
prev_line
[:(
prev_line
.
find
(
"
]
"
))],
print
(
f
"
+
{
title_prev_line
}
"
,
end
=
""
)
callback
=
abbreviations
)
+
prev_line
[(
prev_line
.
find
(
"
]
"
)):],
end
=
""
)
print
()
print
()
return_value
=
1
return_value
=
1
if
(
mkdocs_available
(
arg
.
location
)
and
not
line
.
startswith
(
'
#
'
)
and
not
disabled
):
if
(
mkdocs_available
(
arg
.
location
)
and
not
line
.
startswith
(
'
#
'
)
and
not
disabled
):
if
line
!
=
titlecase
(
line
[:
(
line
.
find
(
"
:
"
)
)
],
title_
line
=
titlecase
(
line
[:
line
.
find
(
"
:
"
)],
callback
=
abbreviations
)
+
line
[
line
.
find
(
"
:
"
):]
callback
=
abbreviations
)
+
line
[(
line
.
find
(
"
:
"
)):]
:
if
line
!=
title_line
:
if
return_value
==
0
and
not
echo_filename
:
if
return_value
==
0
and
not
echo_filename
:
print
(
"
%s
"
%
arg
.
location
)
print
(
f
"
{
arg
.
location
}
"
)
echo_filename
=
True
echo_filename
=
True
print
(
"
-
"
+
line
,
end
=
""
)
print
(
f
"
-
{
line
}
"
,
end
=
""
)
print
(
"
+
"
+
titlecase
(
line
[:(
line
.
find
(
"
:
"
))],
print
(
f
"
+
{
title_line
}
"
,
end
=
""
)
callback
=
abbreviations
)
+
line
[(
line
.
find
(
"
:
"
)):],
end
=
""
)
print
()
print
()
return_value
=
1
return_value
=
1
prev_line
=
line
prev_line
=
line
return
return_value
return
return_value
def
writedata
(
arg
):
def
writedata
(
arg
):
"""
writedata
"""
"""
writedata
"""
# Spelling exceptions
# Spelling exceptions
with
open
(
'
.spelling
'
)
as
fdata
:
with
open
(
'
.spelling
'
,
encoding
=
'
utf-8
'
)
as
fdata
:
spelling
=
fdata
.
readlines
()
spelling
=
fdata
.
readlines
()
# pylint: disable=unused-argument,inconsistent-return-statements
def
abbreviations
(
word
,
**
_
):
def
abbreviations
(
word
,
**
kwargs
):
"""
abbreviations
"""
"""
abbreviations
"""
if
word
+
"
\n
"
in
spelling
:
if
word
+
"
\n
"
in
spelling
:
return
word
return
word
# Open the file and read the lines as a list
# Open the file and read the lines as a list
with
open
(
arg
.
location
)
as
fdata
:
with
open
(
arg
.
location
,
encoding
=
'
utf-8
'
)
as
fdata
:
lines
=
fdata
.
readlines
()
lines
=
fdata
.
readlines
()
with
open
(
arg
.
location
,
'
w
'
)
as
fdata
:
with
open
(
arg
.
location
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
fdata
:
# Loop through the list of lines and titlecase
prev_line
=
lines
[
0
]
if
lines
else
""
# any line beginning with '#'.
prev_line
=
lines
[
0
]
disabled
=
False
disabled
=
False
for
line
in
lines
:
for
line
in
lines
:
disabled
=
linestart
(
line
,
disabled
,
arg
.
test
)
disabled
=
linestart
(
line
,
disabled
,
arg
.
test
)
if
line
.
startswith
(
'
#
'
)
and
not
disabled
:
if
line
.
startswith
(
'
#
'
)
and
not
disabled
:
line
=
titlecase
(
line
[:(
line
.
find
(
"
]
"
))],
line
=
titlecase
(
line
[:
line
.
find
(
"
]
"
)],
callback
=
abbreviations
)
+
line
[
line
.
find
(
"
]
"
):]
callback
=
abbreviations
)
+
line
[(
line
.
find
(
"
]
"
)):]
if
(
line
.
startswith
(
'
---
'
)
or
line
.
startswith
(
'
===
'
))
and
not
disabled
:
if
(
line
.
startswith
(
'
---
'
)
or
line
.
startswith
(
'
===
'
))
and
not
disabled
:
prev_line
=
titlecase
(
prev_line
[:(
prev_line
.
find
(
"
]
"
))],
prev_line
=
titlecase
(
prev_line
[:
prev_line
.
find
(
"
]
"
)],
callback
=
abbreviations
)
+
prev_line
[
prev_line
.
find
(
"
]
"
):]
callback
=
abbreviations
)
+
prev_line
[(
prev_line
.
find
(
"
]
"
)):]
fdata
.
write
(
prev_line
)
fdata
.
write
(
prev_line
)
prev_line
=
line
prev_line
=
line
fdata
.
write
(
prev_line
)
fdata
.
write
(
prev_line
)
...
...
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