2017-11-29 7 views
0

これは可能ですか?Doxygenで関数変数を操作する

あなたが見ることができるように、私はLuaのを使用していますので、私はLuaの使用頻度を文書化したい例えば、このコード

class LuaCamera 
{ 
    public: 
     LuaCamera(lua_State* L); 
     static bool defaultControls; 
     bool FPSCam; 

     int lookAt(lua_State* L); 
     int getRotation(lua_State* L); 
     int setRotation(lua_State* L); 
     // ... 

     virtual ~LuaCamera(); 
     static const char className[]; 
     static const Luna<LuaCamera>::RegType Register[]; 
    protected: 
    private: 
}; 

してください。 Doxygen出力にint setRotation(lua_State* L)を入力する代わりに、void setRotation(int x, int y, int z)とします。同様に、LuaCameraの代わりに出力にCameraという名前のクラスを作成します。

私はクラスの名前を変更してこれを行うために未使用の関数を作成できることを知っていますが、私のプログラムには大量のLua関数があり、それは貧弱なアプローチになります。

アイデア?

+0

:同様のソリューションを探しているかもしれない人のために

は、ここでのpythonファイルにソースです。メソッドの "展開された"形式を文書化し、名前からLua参照を削除したいと思いますか? – BobMorane

+0

うん。私はC++コードでluaの使用法を文書化する必要があります –

+0

そのLuaの使用法をラップしてラッパーにコメントするのが明確になるでしょうか?コードを変更できない場合を除き... – BobMorane

答えて

0

私は、必要な作業を行う非常に簡単なスクリプトを作成することにしました。私は完全に質問を理解していないことを確認

import os; 

path = "include/"; 
output = "doxygen/src/"; 
modOutput = False; 
srcFiles = os.listdir(path); 

def writeFile(fileName, cont): 
    f = open(fileName, "w"); 
    f.write(cont); 
    f.close(); 

def readFile(fileName): 
    cont = open(fileName, "r"); 
    return cont; 

def readFileLines(fileName): 
    return readFile(fileName).readlines(); 

# creates the original files without the \mod option. 
def outputNormalSrc(): 
    for srcFile in srcFiles: 
     fileLines = readFileLines(path + srcFile); 
     newFile = ""; 

     # We want everything in the original src files except for \mod lines. 
     for line in fileLines: 
      if line.find("\mod") >= 0: 
       line = line[ : line.find("\mod")] + "\n"; 

      newFile += line; 

     writeFile(output + srcFile, newFile); 

# creates the modded files for Lua doxygen output. 
def outputModdedSrc(): 
    for srcFile in srcFiles: 
     fileLines = readFileLines(path + srcFile); 
     newFile = ""; 

     foundClass = ""; 
     for line in fileLines: 
      if foundClass == "" and line.find("class") >= 0: 
       foundClass = line[line.find("class")+6 : -1]; 
       break; 
     if foundClass == "": 
      print "WARNING: couldn't find class in src file " + srcFile + ". Skipping."; 
      continue; 

     newFile = "class " + foundClass + "\n{\n"; 

     getLines = False; 
     writeBeforeClass = False; 
     inMod = False; 
     whiteSpaces = ""; 
     for line in fileLines: 
      # We want everything in the block quote. 
      # If the block quote is for the class, put it before the class definition. 
      if line.find("/**") >= 0: 
       getLines = True; 
       if line.find("class") >= 0: 
        writeBeforeClass = ""; 

      # Store the \mod function name. 
      if line.find("\mod") >= 0 and getLines: 
       inMod = line[line.find("\mod")+5 : -1]; 
       line = line[ : line.find("\mod")] + "\n"; 

      # Here we start storing the necessary lines we need for the output. 
      if getLines or line.find("public:") >= 0 or line.find("private:") >= 0 or line.find("protected:") >= 0 or line.find("}") >= 0: 
       if writeBeforeClass != False: 
        writeBeforeClass += line; 
       else: 
        newFile += line; 

      # The end of the block quote. 
      if line.find("*/") >= 0 and getLines: 
       getLines = False; 

       # If we are writing the block quote before the class. 
       if writeBeforeClass != False: 
        newFile = writeBeforeClass + newFile; 
        writeBeforeClass = False; 

       # Add our modded function in place of the normal function. 
       if inMod != False: 
        newFile += whiteSpaces + inMod + ";\n"; 
        inMod = False; 

      # Used to append whitespaces the beginning of modded functions 
      # based on the previous line's whitespaces. 
      whiteSpaces = ""; 
      for i in range(len(line)): 
       if line[i].isspace() == False: 
        break; 
       whiteSpaces += line[i]; 

     # Create the files. 
     writeFile(output + srcFile, newFile); 

def main(): 
    # Choice: Create the original output without the \mod command, 
    #   or with the \mod command to overwrite function definitions. 
    if modOutput: 
     outputModdedSrc(); 
    else: 
     outputNormalSrc(); 

main(); 
関連する問題