mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: command-line -doc, -srcDoc display online documentation
- browser is spawned as a background process to avoid blocking the command-line
This commit is contained in:
@ -18,17 +18,15 @@ FoamFile
|
|||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
{
|
{
|
||||||
docBrowser "firefox %f";
|
docBrowser "firefox -new-tab %f";
|
||||||
|
doxySourceFileExt "_8C.html";
|
||||||
|
|
||||||
|
// Places to search for documentation, http is last in the list
|
||||||
doxyDocDirs
|
doxyDocDirs
|
||||||
(
|
(
|
||||||
"$WM_PROJECT_USER_DIR/html"
|
"$WM_PROJECT_USER_DIR/html"
|
||||||
"~OpenFOAM/html"
|
|
||||||
"$WM_PROJECT_DIR/doc/Doxygen/html"
|
"$WM_PROJECT_DIR/doc/Doxygen/html"
|
||||||
);
|
"https://www.openfoam.com/documentation/cpp-guide/html"
|
||||||
doxySourceFileExts
|
|
||||||
(
|
|
||||||
"App_8C.html"
|
|
||||||
"_8C.html"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,8 @@ License
|
|||||||
#include "sigQuit.H"
|
#include "sigQuit.H"
|
||||||
#include "sigSegv.H"
|
#include "sigSegv.H"
|
||||||
#include "foamVersion.H"
|
#include "foamVersion.H"
|
||||||
|
#include "stringOps.H"
|
||||||
|
#include "CStringList.H"
|
||||||
#include "uncollatedFileOperation.H"
|
#include "uncollatedFileOperation.H"
|
||||||
#include "masterUncollatedFileOperation.H"
|
#include "masterUncollatedFileOperation.H"
|
||||||
|
|
||||||
@ -657,16 +659,16 @@ void Foam::argList::parse
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only display one or the other
|
// Only display one or the other
|
||||||
if (options_.found("srcDoc"))
|
if (options_.found("doc"))
|
||||||
{
|
|
||||||
displayDoc(true);
|
|
||||||
quickExit = true;
|
|
||||||
}
|
|
||||||
else if (options_.found("doc"))
|
|
||||||
{
|
{
|
||||||
displayDoc(false);
|
displayDoc(false);
|
||||||
quickExit = true;
|
quickExit = true;
|
||||||
}
|
}
|
||||||
|
else if (options_.found("srcDoc"))
|
||||||
|
{
|
||||||
|
displayDoc(true);
|
||||||
|
quickExit = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (quickExit)
|
if (quickExit)
|
||||||
{
|
{
|
||||||
@ -1362,59 +1364,72 @@ void Foam::argList::displayDoc(bool source) const
|
|||||||
{
|
{
|
||||||
const dictionary& docDict = debug::controlDict().subDict("Documentation");
|
const dictionary& docDict = debug::controlDict().subDict("Documentation");
|
||||||
List<fileName> docDirs(docDict.lookup("doxyDocDirs"));
|
List<fileName> docDirs(docDict.lookup("doxyDocDirs"));
|
||||||
List<fileName> docExts(docDict.lookup("doxySourceFileExts"));
|
fileName docExt(docDict.lookup("doxySourceFileExt"));
|
||||||
|
|
||||||
// For source code: change foo_8C.html to foo_8C_source.html
|
// For source code: change xxx_8C.html to xxx_8C_source.html
|
||||||
if (source)
|
if (source)
|
||||||
{
|
{
|
||||||
for (fileName& ext : docExts)
|
docExt.replace(".", "_source.");
|
||||||
{
|
|
||||||
ext.replace(".", "_source.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName docFile;
|
fileName url;
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
for (const fileName& dir : docDirs)
|
for (const fileName& dir : docDirs)
|
||||||
{
|
{
|
||||||
for (const fileName& ext : docExts)
|
// http protocols are last in the list
|
||||||
|
if (dir.startsWith("http:") || dir.startsWith("https:"))
|
||||||
{
|
{
|
||||||
docFile = dir/executable_ + ext;
|
url = dir/executable_ + docExt;
|
||||||
docFile.expand();
|
break;
|
||||||
|
|
||||||
if (isFile(docFile))
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (found)
|
|
||||||
|
fileName docFile = stringOps::expand(dir/executable_ + docExt);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
docFile.startsWith("file://")
|
||||||
|
? isFile(docFile.substr(7)) // check part after "file://"
|
||||||
|
: isFile(docFile)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
url = std::move(docFile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (url.empty())
|
||||||
{
|
|
||||||
string docBrowser = getEnv("FOAM_DOC_BROWSER");
|
|
||||||
if (docBrowser.empty())
|
|
||||||
{
|
|
||||||
docDict.lookup("docBrowser") >> docBrowser;
|
|
||||||
}
|
|
||||||
// Can use FOAM_DOC_BROWSER='application file://%f' if required
|
|
||||||
docBrowser.replaceAll("%f", docFile);
|
|
||||||
|
|
||||||
Info<< "Show documentation: " << docBrowser.c_str() << endl;
|
|
||||||
|
|
||||||
Foam::system(docBrowser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "No documentation found for " << executable_
|
<< "No documentation found for " << executable_
|
||||||
<< ", but you can use -help to display the usage\n" << endl;
|
<< ", but you can use -help to display the usage\n" << endl;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string docBrowser = getEnv("FOAM_DOC_BROWSER");
|
||||||
|
if (docBrowser.empty())
|
||||||
|
{
|
||||||
|
docDict.lookup("docBrowser") >> docBrowser;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can use FOAM_DOC_BROWSER='application file://%f' if required
|
||||||
|
if (docBrowser.find("%f") != std::string::npos)
|
||||||
|
{
|
||||||
|
docBrowser.replace("%f", url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
docBrowser += " " + url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split on whitespace to use safer version of Foam::system()
|
||||||
|
|
||||||
|
CStringList command(stringOps::splitSpace(docBrowser));
|
||||||
|
|
||||||
|
Info<<"OpenFOAM-" << Foam::FOAMversion << " documentation:" << nl
|
||||||
|
<< " " << command << nl << endl;
|
||||||
|
|
||||||
|
Foam::system(command, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user