• Add Python script
  • Add Python script

    The python script introduced here shows, how qdoc can be called to generate

    scriptDir = os.path.dirname(os.path.abspath(__file__))

    This line determines the location of the current python scriptfile

    docStyleDir = os.path.abspath(os.path.join(scriptDir, "..", "..", "..", "..", ".."));

    The docStyleDir variable contains now the path to the doc-style root directory.

    In this case it's easy, because the script file and the doc-style are both within the same git repository.
    Other projects may use the doc-style as a subproject to be also able to use a hardcoded relative path. Alternatively you can also use system wide environment variables.

    os.environ["DOCSTYLE_DIR"] = os.path.normpath(docStyleDir);

    The absolute path to doc-style must be stored in the environment variable DOCSTYLE_DIR.
    Note, that this should be an absolute path. Also on windows the variable should contain backslashes instead of forward slashes. This is done using the function os.path.normpath function.

    subprocess.call(["qdoc", os.path.join(scriptDir, "example.qdocconf")])

    Finally, the qdoc is called. This line expects qdoc to be within a directory in the PATH environment variable. But you can also give the full path if you whish.

    Summary of the whole python script

    import subprocess
    import os
    
    scriptDir = os.path.dirname(os.path.abspath(__file__))
    
    docStyleDir = os.path.abspath(os.path.join(scriptDir, "..", "..", "..", "..", ".."));
    
    os.environ["DOCSTYLE_DIR"] = os.path.normpath(docStyleDir);
    
    subprocess.call(["qdoc", os.path.join(scriptDir, "example.qdocconf")])