Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
multiscale
lammps
Commits
efb2a942
Commit
efb2a942
authored
8 years ago
by
Richard Berger
Browse files
Options
Downloads
Patches
Plain Diff
Add utility to detect duplicate anchors in documentation files
parent
3a2da51a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/utils/converters/lammpsdoc/doc_anchor_check.py
+60
-0
60 additions, 0 deletions
doc/utils/converters/lammpsdoc/doc_anchor_check.py
doc/utils/converters/setup.py
+2
-1
2 additions, 1 deletion
doc/utils/converters/setup.py
with
62 additions
and
1 deletion
doc/utils/converters/lammpsdoc/doc_anchor_check.py
0 → 100755
+
60
−
0
View file @
efb2a942
#! /usr/bin/env python3
# LAMMPS Documentation Utilities
#
# Scan for duplicate anchor labels in documentation files
#
# Copyright (C) 2017 Richard Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
re
import
sys
import
argparse
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
scan for duplicate anchor labels in documentation files
'
)
parser
.
add_argument
(
'
files
'
,
metavar
=
'
file
'
,
nargs
=
'
+
'
,
help
=
'
one or more files to scan
'
)
parsed_args
=
parser
.
parse_args
()
anchor_pattern
=
re
.
compile
(
r
'
^:link\(([^,\)]*)\)
'
)
anchors
=
{}
for
filename
in
parsed_args
.
files
:
with
open
(
filename
,
'
rt
'
)
as
f
:
for
line_number
,
line
in
enumerate
(
f
):
m
=
anchor_pattern
.
match
(
line
)
if
m
:
label
=
m
.
group
(
1
)
if
label
in
anchors
:
anchors
[
label
].
append
((
filename
,
line_number
))
else
:
anchors
[
label
]
=
[(
filename
,
line_number
)]
count
=
0
for
label
in
sorted
(
anchors
.
keys
()):
if
len
(
anchors
[
label
])
>
1
:
print
(
label
)
count
+=
1
for
filename
,
line_number
in
anchors
[
label
]:
print
(
"
- %s:%d
"
%
(
filename
,
line_number
))
if
count
>
0
:
print
(
"
Found %d anchor label errors.
"
%
count
)
sys
.
exit
(
1
)
else
:
print
(
"
No anchor label errors.
"
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
doc/utils/converters/setup.py
+
2
−
1
View file @
efb2a942
...
@@ -12,6 +12,7 @@ setup(name='LAMMPS Documentation Utilities',
...
@@ -12,6 +12,7 @@ setup(name='LAMMPS Documentation Utilities',
tests_require
=
[
'
nose
'
],
tests_require
=
[
'
nose
'
],
entry_points
=
{
entry_points
=
{
"
console_scripts
"
:
[
'
txt2html = lammpsdoc.txt2html:main
'
,
"
console_scripts
"
:
[
'
txt2html = lammpsdoc.txt2html:main
'
,
'
txt2rst = lammpsdoc.txt2rst:main
'
]
'
txt2rst = lammpsdoc.txt2rst:main
'
,
'
doc_anchor_check = lammpsdoc.doc_anchor_check: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