From 20d9399d7f495bb4bec1c854cdc8f03f241e0ac2 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 16 Aug 2012 15:00:36 +0100 Subject: [PATCH] ENH: encapsulated retrival of path to doxygen documentation --- .../foamHelp/helpTypes/helpType/helpType.C | 84 ++++++++----------- .../foamHelp/helpTypes/helpType/helpType.H | 3 + 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C index 1443089aa7..ed356b93cb 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.C @@ -37,38 +37,47 @@ namespace Foam // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +Foam::fileName Foam::helpType::doxygenPath() const +{ + const dictionary& docDict = debug::controlDict().subDict("Documentation"); + List docDirs(docDict.lookup("doxyDocDirs")); + + label dirI = -1; + forAll(docDirs, i) + { + if (isDir(docDirs[i].expand())) + { + dirI = i; + break; + } + } + + if (dirI == -1) + { + Info<< "No Doxygen sources found under search paths: " + << docDirs << endl; + return fileName(); + } + + return docDirs[dirI]; +} + + void Foam::helpType::displayDocOptions ( const string& searchStr, const bool exactMatch ) const { - const dictionary& docDict = debug::controlDict().subDict("Documentation"); - List docDirs(docDict.lookup("doxyDocDirs")); + fileName doxyPath(doxygenPath()); - label i = -1; - forAll(docDirs, dirI) + if (!doxyPath.empty()) { - if (isDir(docDirs[dirI].expand())) - { - i = dirI; - break; - } - } - - if (i != -1) - { - Info<< "Found doxygen help in " << docDirs[i].c_str() << nl << endl; - - string docBrowser = getEnv("FOAM_DOC_BROWSER"); - if (docBrowser.empty()) - { - docDict.lookup("docBrowser") >> docBrowser; - } + Info<< "Found doxygen help in " << doxyPath.c_str() << nl << endl; doxygenXmlParser parser ( - docDirs[i]/"../DTAGS", + doxyPath/"../DTAGS", "tagfile", searchStr, exactMatch @@ -76,11 +85,6 @@ void Foam::helpType::displayDocOptions Info<< "Valid types include:" << nl << SortableList(parser.toc()); } - else - { - Info<< "No Doxygen sources found under search paths: " - << docDirs << endl; - } } @@ -91,32 +95,23 @@ void Foam::helpType::displayDoc const bool exactMatch ) const { - const dictionary& docDict = debug::controlDict().subDict("Documentation"); - List docDirs(docDict.lookup("doxyDocDirs")); + fileName doxyPath(doxygenPath()); - label i = -1; - forAll(docDirs, dirI) + if (!doxyPath.empty()) { - if (isDir(docDirs[dirI].expand())) - { - i = dirI; - break; - } - } - - if (i != -1) - { - Info<< "Found doxygen help in " << docDirs[i].c_str() << nl << endl; + Info<< "Found doxygen help in " << doxyPath.c_str() << nl << endl; string docBrowser = getEnv("FOAM_DOC_BROWSER"); if (docBrowser.empty()) { + const dictionary& docDict = + debug::controlDict().subDict("Documentation"); docDict.lookup("docBrowser") >> docBrowser; } doxygenXmlParser parser ( - docDirs[i]/"../DTAGS", + doxyPath/"../DTAGS", "tagfile", searchStr, exactMatch @@ -131,7 +126,7 @@ void Foam::helpType::displayDoc { fileName docFile ( - docDirs[i]/parser.subDict(className).lookup("filename") + doxyPath/parser.subDict(className).lookup("filename") ); // can use FOAM_DOC_BROWSER='application file://%f' if required @@ -159,11 +154,6 @@ void Foam::helpType::displayDoc << exit(FatalError); } } - else - { - Info<< "No Doxygen sources found under search paths: " - << docDirs << endl; - } } diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H index d1ccf14c62..3ce63ad713 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpType.H @@ -58,6 +58,9 @@ class helpType protected: + //- Return file path to the Doxygen sources (if available) + fileName doxygenPath() const; + //- Display the list of documentation options void displayDocOptions (