From e8d12885275e33c96df5012a889be7bb8f893065 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 22 Feb 2020 11:46:31 -0500 Subject: [PATCH] added script to check for missing packages in package tables in manual --- doc/Makefile | 11 +++++ doc/src/Build_basics.rst | 17 ++++---- doc/src/Manual_build.rst | 27 +++++++------ doc/utils/check-packages.py | 81 +++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 21 deletions(-) create mode 100755 doc/utils/check-packages.py diff --git a/doc/Makefile b/doc/Makefile index 124c2bea7b..f9de6760c3 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -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): diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 2a940c7ea7..4788d93689 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -402,14 +402,15 @@ LAMMPS source distribution. .. code-block:: bash - make html # create HTML doc pages in html directory - make pdf # create Developer.pdf and Manual.pdf in this directory - make fetch # fetch HTML and PDF files from LAMMPS web site - make clean # remove all intermediate files - 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 spelling # spell-check the manual + make html # create HTML doc pages in html directory + make pdf # create Developer.pdf and Manual.pdf in this directory + make fetch # fetch HTML and PDF files from LAMMPS web site + make clean # remove all intermediate files + 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 Thus "make html" will create a "doc/html" directory with the HTML format diff --git a/doc/src/Manual_build.rst b/doc/src/Manual_build.rst index ce13033a5a..707f81d8da 100644 --- a/doc/src/Manual_build.rst +++ b/doc/src/Manual_build.rst @@ -58,19 +58,20 @@ the doc directory. Documentation Build Options: - make html # generate HTML in html dir using Sphinx - make html-offline # generate offline viewable HTML in html-offline dir using Sphinx - make pdf # generate 2 PDF files (Manual.pdf,Developer.pdf) - # in doc dir via htmldoc and pdflatex - make fetch # fetch HTML doc pages and 2 PDF files from web site - # as a tarball and unpack into html dir and 2 PDFs - make epub # generate LAMMPS.epub in ePUB format using Sphinx - make mobi # generate LAMMPS.mobi in MOBI format using ebook-convert - make clean # remove intermediate RST files created by HTML build - 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 spelling # spell-check the manual + make html # generate HTML in html dir using Sphinx + make html-offline # generate offline viewable HTML in html-offline dir using Sphinx + make pdf # generate 2 PDF files (Manual.pdf,Developer.pdf) + # in doc dir via htmldoc and pdflatex + make fetch # fetch HTML doc pages and 2 PDF files from web site + # as a tarball and unpack into html dir and 2 PDFs + make epub # generate LAMMPS.epub in ePUB format using Sphinx + make mobi # generate LAMMPS.mobi in MOBI format using ebook-convert + make clean # remove intermediate RST files created by HTML build + 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 ---------- diff --git a/doc/utils/check-packages.py b/doc/utils/check-packages.py new file mode 100755 index 0000000000..616aaa6814 --- /dev/null +++ b/doc/utils/check-packages.py @@ -0,0 +1,81 @@ +#!/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) +