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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
David Ciz
docs.it4i.cz
Commits
72ebc18f
Commit
72ebc18f
authored
8 years ago
by
Lubomir Prda
Browse files
Options
Downloads
Patches
Plain Diff
Created script for header capitalization
parent
804112d5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+7
-0
7 additions, 0 deletions
.gitlab-ci.yml
scripts/titlemd.py
+40
-0
40 additions, 0 deletions
scripts/titlemd.py
scripts/titlemd_test.py
+50
-0
50 additions, 0 deletions
scripts/titlemd_test.py
with
97 additions
and
0 deletions
.gitlab-ci.yml
+
7
−
0
View file @
72ebc18f
...
...
@@ -19,6 +19,13 @@ two spaces:
-
echo "== Files having more than one space betwee two characters =="
-
find docs.it4i/ -name '*.md' -exec grep "[[:alpha:]] [[:alpha:]]" -l {} +
capitalize
:
stage
:
test
image
:
davidhrbac/docker-mkdocscheck:latest
allow_failure
:
true
script
:
-
find docs.it4i/ -name '*.md' -print0 | xargs -0 -n1 scripts/titlemd_test.py
spell check
:
stage
:
test
image
:
davidhrbac/docker-npmcheck:latest
...
...
This diff is collapsed.
Click to expand it.
scripts/titlemd.py
0 → 100755
+
40
−
0
View file @
72ebc18f
#!/usr/bin/python
import
fnmatch
import
os
import
sys
try
:
from
titlecase
import
titlecase
except
ImportError
:
print
(
"
Please install titlecase
"
)
def
main
(
location
):
# Open the file and read the lines as a list
with
open
(
location
)
as
f
:
lines
=
f
.
readlines
()
with
open
(
location
,
'
w
'
)
as
f
:
# Loop through the list of lines and titlecase
# any line beginning with '#'.
prev_line
=
lines
.
pop
(
0
)
disabled
=
0
for
line
in
lines
:
if
line
.
startswith
(
"
``
"
)
and
disabled
==
0
:
disabled
=
1
else
:
if
line
.
startswith
(
"
``
"
)
and
disabled
==
1
:
disabled
=
0
if
line
.
startswith
(
'
#
'
)
and
disabled
==
0
:
line
=
titlecase
(
line
[:(
line
.
find
(
"
]
"
))])
+
line
[(
line
.
find
(
"
]
"
)):]
if
line
.
startswith
(
'
---
'
)
or
line
.
startswith
(
'
===
'
):
prev_line
=
titlecase
(
prev_line
[:(
prev_line
.
find
(
"
]
"
))])
+
prev_line
[(
prev_line
.
find
(
"
]
"
)):]
f
.
write
(
prev_line
)
prev_line
=
line
f
.
write
(
prev_line
)
if
__name__
==
"
__main__
"
:
try
:
main
(
sys
.
argv
[
1
])
except
IndexError
:
main
(
'
.
'
)
This diff is collapsed.
Click to expand it.
scripts/titlemd_test.py
0 → 100755
+
50
−
0
View file @
72ebc18f
#!/usr/bin/env python
from
__future__
import
print_function
import
fnmatch
import
os
import
sys
try
:
from
titlecase
import
titlecase
except
ImportError
:
print
(
"
Please install titlecase
"
)
def
main
(
location
):
# Open the file and read the lines as a list
with
open
(
location
)
as
f
:
lines
=
f
.
readlines
()
# Loop through the list of lines and titlecase
# any line beginning with '#'.
return_value
=
0
prev_line
=
lines
.
pop
(
0
)
disabled
=
0
print
(
`location`
)
for
line
in
lines
:
if
line
.
startswith
(
"
``
"
)
and
disabled
==
0
:
disabled
=
1
else
:
if
line
.
startswith
(
"
``
"
)
and
disabled
==
1
:
disabled
=
0
if
line
.
startswith
(
'
#
'
)
and
disabled
==
0
:
if
line
!=
titlecase
(
line
):
print
()
print
(
"
-
"
+
line
,
end
=
""
)
print
(
"
+
"
+
titlecase
(
line
[:(
line
.
find
(
"
]
"
))])
+
line
[(
line
.
find
(
"
]
"
)):],
end
=
""
)
return_value
=
1
if
line
.
startswith
(
'
---
'
)
or
line
.
startswith
(
'
===
'
):
if
prev_line
!=
titlecase
(
prev_line
):
print
()
print
(
"
-
"
+
prev_line
,
end
=
""
)
print
(
"
+
"
+
titlecase
(
prev_line
[:(
prev_line
.
find
(
"
]
"
))])
+
prev_line
[(
prev_line
.
find
(
"
]
"
)):],
end
=
""
)
return_value
=
1
prev_line
=
line
if
return_value
==
0
:
print
(
"
==Ok==
"
)
exit
(
return_value
)
if
__name__
==
"
__main__
"
:
try
:
main
(
sys
.
argv
[
1
])
except
IndexError
:
main
(
'
.
'
)
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