Skip to content

Commit

Permalink
Documents examples of CLI tools. All docs pass. All tests pass. Demo …
Browse files Browse the repository at this point in the history
…is the same.
  • Loading branch information
paulross committed Nov 17, 2017
1 parent c483b9d commit 48647ee
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 47 deletions.
25 changes: 25 additions & 0 deletions src/cpip/CPIPMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,31 @@
-J INCSYS, --sys INCSYS
Add system include search path. [default: []]
Example, from tthe CPIP directory:
.. code-block:: console
(CPIP36) $ src/cpip/CPIPMain.py -l20 -j1 -o demo/output -J demo/sys/ -I demo/usr/ demo/src/main.cpp
2017-11-17 10:29:16,370 INFO preprocessFileToOutput(): demo/src/main.cpp
2017-11-17 10:29:16,371 INFO TU in HTML:
2017-11-17 10:29:16,372 INFO tmp/output_normal_02/main.cpp.html
2017-11-17 10:29:16,391 INFO preprocessFileToOutput(): Processing TU done.
2017-11-17 10:29:16,391 INFO Macro history to:
2017-11-17 10:29:16,391 INFO tmp/output_normal_02
2017-11-17 10:29:16,400 INFO Include graph (SVG) to:
2017-11-17 10:29:16,401 INFO tmp/output_normal_02/main.cpp.include.svg
2017-11-17 10:29:16,423 INFO Writing include graph (TEXT) to:
2017-11-17 10:29:16,423 INFO tmp/output_normal_02/main.cpp.include.svg
2017-11-17 10:29:16,424 INFO Conditional compilation graph in HTML:
2017-11-17 10:29:16,424 INFO tmp/output_normal_02/main.cpp.ccg.html
2017-11-17 10:29:16,431 INFO Done: demo/src/main.cpp
2017-11-17 10:29:16,432 INFO ITU in HTML: .../main.cpp
2017-11-17 10:29:16,448 INFO ITU in HTML: .../system.h
2017-11-17 10:29:16,453 INFO ITU in HTML: .../user.h
2017-11-17 10:29:16,462 INFO preprocessFileToOutput(): demo/src/main.cpp DONE
CPU time = 0.087 (S)
Bye, bye!
"""
__author__ = 'Paul Ross'
__date__ = '2011-07-10'
Expand Down
13 changes: 10 additions & 3 deletions src/cpip/DupeRelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Paul Ross: [email protected]
"""
DupeRelink.py -- Searches for HTML files that are the same, writes a single
"""This can be used after CPIP has processed a directory of code.
In that case there are usually multiple copies of the HTML for common header
files which wastes a lot of disk space.
DupeRelink.py searches for HTML files that are the same, writes a single
file into a common area and deletes all the others. Then re-links all the
remaining HTML files that linked to the original files to link to the file
remaining HTML files that linked to the original file to link to the file
in the common area. This is a space saving optimisation after CPIPMain.py
has processed a directory of source files.
Typically this can halve the disk space needed.
It only needs a single argument, the output directory of CPIPMain.py.
.. code-block:: console
(CPIP36) $ python src/cpip/DupeRelink.py --help
Expand Down
41 changes: 23 additions & 18 deletions src/cpip/FileStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@
# Paul Ross: [email protected]
"""Provides a command line tool for finding out information on files:
Help:
.. code-block:: console
$ python src/cpip/FileStatus.py --help
Cmd: src/cpip/FileStatus.py --help
Usage: FileStatus.py [options] dir
Counts files and sizes.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-g GLOB, --glob=GLOB Space separated list of file match patterns. [default:
*.py]
-l LOGLEVEL, --loglevel=LOGLEVEL
Log Level (debug=10, info=20, warning=30, error=40,
critical=50) [default: 30]
-r Recursive. [default: False]
Example:
.. code-block:: console
$ python3 src/cpip/FileStatus.py -r src/cpip/
Expand Down Expand Up @@ -161,24 +183,7 @@ def write(self, theS=sys.stdout):
theS.write('\n')

def main():
"""Prints out the status of files in a directory:
.. code-block:: console
$ python ../src/cpip/FileStatus.py --help
Cmd: ../src/cpip/FileStatus.py --help
Usage: FileStatus.py [options] dir
Counts files and sizes.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-g GLOB, --glob=GLOB Space separated list of file match patterns. [default:
*.py]
-l LOGLEVEL, --loglevel=LOGLEVEL
Log Level (debug=10, info=20, warning=30, error=40,
critical=50) [default: 30]
-r Recursive. [default: False]
"""Main entry point.
"""
usage = """usage: %prog [options] dir
Counts files and sizes."""
Expand Down
70 changes: 45 additions & 25 deletions src/cpip/IncList.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,51 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Paul Ross: [email protected]
"""Command line tool to list included file paths
"""Command line tool to list included file paths.
Help:
.. code-block:: none
Usage: IncList.py [options] files...
Preprocess the files and lists included files.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-k Keep going. [default: False]
-l LOGLEVEL, --loglevel=LOGLEVEL
Log Level (debug=10, info=20, warning=30, error=40,
critical=50) [default: 30]
-n Nervous mode (do no harm). [default: False]
-p Ignore pragma statements. [default: False]
-I INCUSR, --usr=INCUSR
Add user include search path. [default: []]
-J INCSYS, --sys=INCSYS
Add system include search path. [default: []]
-P PREINC, --pre=PREINC
Add pre-include file path. [default: []]
-D DEFINES, --define=DEFINES
Add macro defintions of the form name<=defintion>.
These are introduced into the environment before any
pre-include. [default: []]
Example from the CPIP directory:
.. code-block:: console
(CPIP36) $ src/cpip/IncList.py -l20 -J demo/sys/ -I demo/usr/ demo/src/main.cpp
2017-11-17 11:24:40,597 INFO Preprocessing TU: demo/src/main.cpp
2017-11-17 11:24:40,605 INFO Preprocessing TU done.
2017-11-17 11:24:40,606 INFO All done.
---------------------------- Included files [3] ---------------------------
demo/src/main.cpp
demo/sys/system.h
demo/usr/user.h
------------------------------ Included files -----------------------------
CPU time = 0.009 (S)
Bye, bye!
"""
__author__ = 'Paul Ross'
__date__ = '2011-07-10'
Expand Down Expand Up @@ -90,30 +134,6 @@ def preProcessForIncludes(theItu, incUsr, incSys, theDefineS, preIncS, keepGoing
def main():
"""Main command line entry point. Help:
.. code-block:: none
Usage: IncList.py [options] files...
Preprocess the files and lists included files.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-k Keep going. [default: False]
-l LOGLEVEL, --loglevel=LOGLEVEL
Log Level (debug=10, info=20, warning=30, error=40,
critical=50) [default: 30]
-n Nervous mode (do no harm). [default: False]
-p Ignore pragma statements. [default: False]
-I INCUSR, --usr=INCUSR
Add user include search path. [default: []]
-J INCSYS, --sys=INCSYS
Add system include search path. [default: []]
-P PREINC, --pre=PREINC
Add pre-include file path. [default: []]
-D DEFINES, --define=DEFINES
Add macro defintions of the form name<=defintion>.
These are introduced into the environment before any
pre-include. [default: []]
"""
usage = """usage: %prog [options] files...
Expand Down
56 changes: 55 additions & 1 deletion src/cpip/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# Paul Ross: [email protected]
"""
cpip.cpp -- Pretends to be like cpp, Will take options and a file (or stdin)
cpp.py -- Pretends to be like cpp, Will take options and a file (or stdin)
and process it.
@author: Paul Ross
Expand Down Expand Up @@ -76,6 +76,60 @@
-J INCSYS, --sys INCSYS
Add system include search path. [default: []]
Example:
.. code-block:: console
(CPIP36) $ python src/cpip/cpp.py -E -J demo/sys/ -I demo/usr/ demo/src/main.cpp
----------------------------- Translation unit ----------------------------
int main(char **argv, int argc)
{
printf("Bonjour tout le monde\\n");
return 1;
}
-------------------------- END: Translation unit --------------------------
Using ``-t`` to show tokens:
.. code-block:: console
(CPIP36) $ python src/cpip/cpp.py -t -E -J demo/sys/ -I demo/usr/ demo/src/main.cpp
----------------------------- Translation unit ----------------------------
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="int", tt=identifier, line=True, prev=False, ?=False)
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="main", tt=identifier, line=True, prev=False, ?=False)
PpToken(t="(", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="char", tt=identifier, line=True, prev=False, ?=False)
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="*", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="*", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="argv", tt=identifier, line=True, prev=False, ?=False)
PpToken(t=",", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="int", tt=identifier, line=True, prev=False, ?=False)
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="argc", tt=identifier, line=True, prev=False, ?=False)
PpToken(t=")", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="{", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="printf", tt=identifier, line=True, prev=False, ?=False)
PpToken(t="(", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t=""Bonjour tout le monde\\n"", tt=string-literal, line=False, prev=False, ?=False)
PpToken(t=")", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t=";", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="return", tt=identifier, line=True, prev=False, ?=False)
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="1", tt=pp-number, line=False, prev=False, ?=False)
PpToken(t=";", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False)
PpToken(t="}", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False)
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False)
-------------------------- END: Translation unit --------------------------
"""
from __future__ import print_function

Expand Down

0 comments on commit 48647ee

Please sign in to comment.