From 405eb63a5133b8772927a207b108100083ac638d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 21 Jan 2020 11:39:29 -0500 Subject: [PATCH] update sphinx extension to automatically pad lists to fill tables and avoid errors processing the documentation --- doc/src/Commands_all.rst | 12 +++++------- doc/src/Commands_bond.rst | 5 ----- doc/src/Commands_compute.rst | 4 +--- doc/src/Commands_fix.rst | 4 ---- doc/src/Commands_kspace.rst | 1 - doc/src/Commands_pair.rst | 1 - doc/src/_ext/table_from_list.py | 8 ++++++-- 7 files changed, 12 insertions(+), 23 deletions(-) diff --git a/doc/src/Commands_all.rst b/doc/src/Commands_all.rst index 1576b23714..6e87ffbad6 100644 --- a/doc/src/Commands_all.rst +++ b/doc/src/Commands_all.rst @@ -132,10 +132,8 @@ An alphabetic list of all general LAMMPS commands. * :doc:`units ` * :doc:`variable ` * :doc:`velocity ` - * :doc:`write\_coeff ` - * :doc:`write\_data ` - * :doc:`write\_dump ` - * :doc:`write\_restart ` - * - * - * + * :doc:`write_coeff ` + * :doc:`write_data ` + * :doc:`write_dump ` + * :doc:`write_restart ` + diff --git a/doc/src/Commands_bond.rst b/doc/src/Commands_bond.rst index 27ff2d19da..5412675ee4 100644 --- a/doc/src/Commands_bond.rst +++ b/doc/src/Commands_bond.rst @@ -47,7 +47,6 @@ OPT. * :doc:`oxrna2/fene ` * :doc:`quartic (o) ` * :doc:`table (o) ` - * .. _angle: @@ -89,7 +88,6 @@ OPT. * :doc:`quartic (o) ` * :doc:`sdk (o) ` * :doc:`table (o) ` - * .. _dihedral: @@ -127,8 +125,6 @@ OPT. * :doc:`spherical ` * :doc:`table (o) ` * :doc:`table/cut ` - * - * .. _improper: @@ -162,4 +158,3 @@ OPT. * :doc:`ring (o) ` * :doc:`sqdistharm ` * :doc:`umbrella (o) ` - * diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 01943ac803..79f0e8d83f 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -163,6 +163,4 @@ KOKKOS, o = USER-OMP, t = OPT. * :doc:`vcm/chunk ` * :doc:`voronoi/atom ` * :doc:`xrd ` - * - * - * + diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index c1c97b6e59..0b6b892b9d 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -240,7 +240,3 @@ OPT. * :doc:`wall/region ` * :doc:`wall/region/ees ` * :doc:`wall/srd ` - * - * - * - * diff --git a/doc/src/Commands_kspace.rst b/doc/src/Commands_kspace.rst index 3a23520171..be953c5277 100644 --- a/doc/src/Commands_kspace.rst +++ b/doc/src/Commands_kspace.rst @@ -37,4 +37,3 @@ OPT. * :doc:`pppm/stagger ` * :doc:`pppm/tip4p (o) ` * :doc:`scafacos ` - * diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index 1d4f832015..28f50bfd8e 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -257,4 +257,3 @@ OPT. * :doc:`yukawa (gko) ` * :doc:`yukawa/colloid (go) ` * :doc:`zbl (gko) ` - * diff --git a/doc/src/_ext/table_from_list.py b/doc/src/_ext/table_from_list.py index 715a3c2488..da82069d87 100644 --- a/doc/src/_ext/table_from_list.py +++ b/doc/src/_ext/table_from_list.py @@ -1,6 +1,6 @@ from docutils import nodes from sphinx.util.docutils import SphinxDirective -from docutils.nodes import Element, Node +from docutils.nodes import Element, Node, list_item from typing import Any, Dict, List from sphinx import addnodes from sphinx.util import logging @@ -26,8 +26,12 @@ class TableFromList(SphinxDirective): raise SphinxError('table_from_list content is not a list') fulllist = node.children[0] + # fill list with empty items to have a number of entries + # that is divisible by ncolumns if (len(fulllist) % ncolumns) != 0: - raise SphinxError('number of list elements not a multiple of column number') + missing = int(ncolumns - (len(fulllist) % ncolumns)) + for i in range(0,missing): + fulllist += list_item() table = nodes.table() tgroup = nodes.tgroup(cols=ncolumns)