Commit 099117dd authored by Mark Olesen's avatar Mark Olesen
Browse files

argList + IOobject write-headers modifications

  * new -srcDoc option to display doxygen-processed source code
  * display standard options -help/-doc/-srcDoc at end of usage
  * consolidate code when writing IOobject headers
  * drop writeLogbanner and add optional bool to writeBanner
  * minor formatting changes
parent 763cc5e4
......@@ -329,12 +329,9 @@ public:
// Writing
//- Write the standard OpenFOAM file/dictionary banner
// Optionally without -*- C++ -*- editor hint (eg, for logs)
template<class Stream>
static inline void writeBanner(Stream& os);
//- Write the standard OpenFOAM log banner
template<class Stream>
static inline void writeLogBanner(Stream& os);
static inline void writeBanner(Stream& os, bool noHint=false);
//- Write the standard file section divider
template<class Stream>
......
......@@ -29,48 +29,34 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Stream>
inline void Foam::IOobject::writeBanner(Stream& os)
inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
{
static bool spacesSet = false;
static char spaces[80];
static char spaces[40];
if (!spacesSet)
{
memset(spaces, ' ', 80);
memset(spaces, ' ', 40);
spaces[38 - strlen(Foam::FOAMversion)] = '\0';
spacesSet = true;
}
os <<
"/*--------------------------------*- C++ -*----------------------------------*\\\n"
"| ========= | |\n"
"| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n"
"| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n"
"| \\\\ / A nd | Web: http://www.openfoam.org |\n"
"| \\\\/ M anipulation | |\n"
"\\*---------------------------------------------------------------------------*/\n";
}
template<class Stream>
inline void Foam::IOobject::writeLogBanner(Stream& os)
{
static bool spacesSet = false;
static char spaces[80];
if (!spacesSet)
if (noHint)
{
memset(spaces, ' ', 80);
spaces[38 - strlen(Foam::FOAMversion)] = '\0';
spacesSet = true;
os <<
"/*---------------------------------------------------------------------------*\\\n";
}
else
{
os <<
"/*--------------------------------*- C++ -*----------------------------------*\\\n";
}
os <<
"/*---------------------------------------------------------------------------*\\\n"
"| ========= | |\n"
"| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n"
"| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n"
"| \\\\ / A nd | Web: http://www.openfoam.org |\n"
"| \\\\ / A nd | Web: http://www.OpenFOAM.org |\n"
"| \\\\/ M anipulation | |\n"
"\\*---------------------------------------------------------------------------*/\n";
}
......
......@@ -37,8 +37,8 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
if (!os.good())
{
Info<< "IOobject::writeHeader(Ostream&) : "
<< "no stream open for write"
<< endl << os.info() << endl;
<< "no stream open for write" << nl
<< os.info() << endl;
return false;
}
......@@ -49,16 +49,14 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
<< " format " << os.format() << ";\n"
<< " class " << type() << ";\n";
// outdent for visibility and more space
if (note().size())
{
os << " note " << note() << ";\n";
os << " note " << note() << ";\n";
}
// writing without quotes would look nicer
os << " object " << name() << ";\n"
//<< " instance " << instance()/local() << ";\n"
//<< " local " << local() << ";\n"
<< " location " << instance()/local() << ";\n"
os << " location " << instance()/local() << ";\n"
<< " object " << name() << ";\n"
<< "}" << nl;
writeDivider(os);
......
......@@ -186,7 +186,7 @@ Foam::argList::argList
// Print the banner once only for parallel runs
if (Pstream::master())
{
IOobject::writeLogBanner(Info);
IOobject::writeBanner(Info, true);
}
// convert argv -> args_ and capture ( ... ) lists
......@@ -252,19 +252,30 @@ Foam::argList::argList
args_.setSize(nArgs);
// Help options:
// -doc display the documentation in browser
// -help print the usage
if (options_.found("doc") || options_.found("help"))
// Help/documentation options:
// -help print the usage
// -doc display application documentation in browser
// -srcDoc display source code in browser
if
(
options_.found("help")
|| options_.found("doc")
|| options_.found("srcDoc")
)
{
if (options_.found("help"))
{
printUsage();
}
if (options_.found("doc"))
// only display one or the other
if (options_.found("srcDoc"))
{
displayDoc(true);
}
else if (options_.found("doc"))
{
displayDoc();
displayDoc(false);
}
::exit(0);
......@@ -578,12 +589,9 @@ void Foam::argList::printUsage() const
++iter
)
{
Info<< ' ' << '<' << iter().c_str() << '>';
Info<< " <" << iter().c_str() << '>';
}
// place -doc and -help up front
Info<< " [-doc] [-help]";
for
(
HashTable<string>::iterator iter = validOptions.begin();
......@@ -601,16 +609,27 @@ void Foam::argList::printUsage() const
Info<< ']';
}
Info<< endl;
// place help/doc options of the way at the end,
// but with an extra space to separate it a little
Info<< " [-help] [-doc] [-srcDoc]" << endl;
}
void Foam::argList::displayDoc() const
void Foam::argList::displayDoc(bool source) const
{
const dictionary& docDict = debug::controlDict().subDict("Documentation");
List<fileName> docDirs(docDict.lookup("doxyDocDirs"));
List<fileName> docExts(docDict.lookup("doxySourceFileExts"));
// for source code: change foo_8C.html to foo_8C-source.html
if (source)
{
forAll(docExts, extI)
{
docExts[extI].replace(".", "-source.");
}
}
fileName docFile;
bool found = false;
......@@ -618,7 +637,7 @@ void Foam::argList::displayDoc() const
{
forAll(docExts, extI)
{
docFile = docDirs[dirI]/executable() + docExts[extI];
docFile = docDirs[dirI]/executable_ + docExts[extI];
docFile.expand();
if (exists(docFile))
......
......@@ -27,18 +27,18 @@ Class
Description
Extract command arguments and options from the supplied
@a argc and @a argv.
@a argc and @a argv parameters.
Sequences with "(" ... ")" are transformed into a stringList.
For example,
@verbatim
program -listFiles \( *.txt \)
@endverbatim
in which the backslash-escaping has been used to avoid shell expansions,
would create a stringList:
@verbatim
( "file1.txt" "file2.txt" ... "fileN.txt" )
@endverbatim
The backslash-escaping has been used to avoid shell expansions.
@par Default command-line options
@param -case \<dir\> \n
......@@ -47,6 +47,8 @@ Description
specify case as a parallel job
@param -doc \n
display the documentation in browser
@param -srcDoc \n
display the source documentation in browser
@param -help \n
print the usage
......@@ -130,14 +132,14 @@ public:
//- A list of valid parallel options
static HashTable<string> validParOptions;
//! @cond ignore documentation for this class
//! @cond ignoreDocumentation
class initValidTables
{
public:
initValidTables();
};
//! @endcond
//! @endcond ignoreDocumentation
// Constructors
......@@ -148,8 +150,8 @@ public:
(
int& argc,
char**& argv,
bool checkArgs = true,
bool checkOpts = true
bool checkArgs=true,
bool checkOpts=true
);
......@@ -196,8 +198,7 @@ public:
return globalCase_;
}
//- Return case name for parallel run
// or the global case for a serial run
//- Return case name for parallel run or the global case for a serial run
const fileName& caseName() const
{
return case_;
......@@ -222,13 +223,14 @@ public:
void printUsage() const;
//- Display documentation in browser
void displayDoc() const;
// Optionally display the application source code
void displayDoc(bool source=false) const;
// Check
//- Check argument list
bool check(bool checkArgs = true, bool checkOpts = true) const;
bool check(bool checkArgs=true, bool checkOpts=true) const;
//- Check root path and case path
bool checkRootCase() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment