Unverified Commit e8d12885 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

added script to check for missing packages in package tables in manual

parent ffabee6a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ help:
	@echo "  clean-all     reset the entire build environment"
	@echo "  anchor_check  scan for duplicate anchor labels"
	@echo "  style_check   check for complete and consistent style lists"
	@echo "  package_check check for complete and consistent package lists"
	@echo "  spelling      spell-check the manual"

# ------------------------------------------
@@ -65,6 +66,7 @@ html: $(ANCHORCHECK)
		sphinx-build $(SPHINXEXTRA) -b html -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) html ;\
		echo "############################################" ;\
		rst_anchor_check src/*.rst ;\
		python utils/check-packages.py -s ../src -d src ;\
		env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\
		python utils/check-styles.py -s ../src -d src ;\
		echo "############################################" ;\
@@ -93,6 +95,7 @@ html-offline: $(ANCHORCHECK) $(MATHJAX)
			-b html -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) html-offline ;\
		echo "############################################" ;\
		rst_anchor_check src/*.rst ;\
		python utils/check-packages.py -s ../src -d src ;\
		env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\
		python utils/check-styles.py -s ../src -d src ;\
		echo "############################################" ;\
@@ -158,6 +161,7 @@ pdf: $(ANCHORCHECK)
		sphinx-build $(SPHINXEXTRA) -b latex -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) latex ;\
		echo "############################################" ;\
		rst_anchor_check src/*.rst ;\
		python utils/check-packages.py -s ../src -d src ;\
		env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\
		python utils/check-styles.py -s ../src -d src ;\
		echo "############################################" ;\
@@ -208,6 +212,13 @@ style_check :
		deactivate ;\
	)

package_check :
	@(\
		. $(VENV)/bin/activate ;\
		python utils/check-packages.py -s ../src -d src ;\
		deactivate ;\
	)

# ------------------------------------------

$(VENV):
+9 −8
Original line number Diff line number Diff line
@@ -409,6 +409,7 @@ LAMMPS source distribution.
  make clean-all     # reset the entire doc build environment
  make anchor_check  # scan for duplicate anchor labels
  make style_check   # check for complete and consistent style lists
  make package_check # check for complete and consistent package lists
  make spelling      # spell-check the manual


+14 −13
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ the doc directory.
   make clean-all     # remove entire build folder and any cached data
   make anchor_check  # check for duplicate anchor labels
   make style_check   # check for complete and consistent style lists
   make package_check # check for complete and consistent package lists
   make spelling      # spell-check the manual

----------
+81 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

from __future__ import print_function
from glob import glob
from argparse import ArgumentParser
import os, re, sys

parser = ArgumentParser(prog='check-packages.py',
                        description="Check package table completeness")

parser.add_argument("-v", "--verbose",
                    action='store_const',
                    const=True, default=False,
                    help="Enable verbose output")

parser.add_argument("-d", "--doc",
                    help="Path to LAMMPS documentation sources")
parser.add_argument("-s", "--src",
                    help="Path to LAMMPS sources")

args = parser.parse_args()
verbose = args.verbose
src = args.src
doc = args.doc

if not args.src or not args.doc:
  parser.print_help()
  sys.exit(1)

if not os.path.isdir(src):
    sys.exit("LAMMPS source path %s does not exist" % src)

if not os.path.isdir(doc):
    sys.exit("LAMMPS documentation source path %s does not exist" % doc)

pkgdirs = glob(os.path.join(src, '[A-Z][A-Z]*'))
dirs = re.compile(".*/([0-9A-Z-]+)$")
user = re.compile("USER-.*")

stdpkg = []
usrpkg = []

# find package names and add to standard and user package lists.
# anything starting with at least two upper case characters, is a
# folder, and is not called 'MAKE' is a package 

for d in pkgdirs:
  pkg = dirs.match(d)[1]
  if not os.path.isdir(os.path.join(src,pkg)): continue
  if pkg in ['DEPEND','MAKE','STUBS']: continue
  if user.match(pkg):
    usrpkg.append(pkg)
  else:
    stdpkg.append(pkg)

print("Found %d standard and %d user packages" % (len(stdpkg),len(usrpkg)))

counter = 0
fp = open(os.path.join(doc,'Packages_standard.rst'))
text = fp.read()
fp.close()
matches = re.findall(':ref:`([A-Z0-9-]+) <[A-Z0-9-]+>`',text,re.MULTILINE)
for p in stdpkg:
  if not p in matches:
    ++counter
    print("Standard package %s missing in Packages_standard.rst"
          % p)

fp = open(os.path.join(doc,'Packages_user.rst'))
text = fp.read()
fp.close()
matches = re.findall(':ref:`([A-Z0-9-]+) <[A-Z0-9-]+>`',text,re.MULTILINE)
for p in usrpkg:
  if not p in matches:
    ++counter
    print("User package %s missing in Packages_user.rst"
          % p)

if counter:
    print("Found %d issue(s) with package lists" % counter)