2017-11-29 3 views
0

가능합니까? 예를 들어Doxygen에서 함수 변수 조작

테이크이 코드에서 볼 수 있듯이, 내가 루아를 사용하고, 그래서 루아 - 사용 내용을 문서화 할

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: 
}; 

. int setRotation(lua_State* L)을 Doxygen 출력으로 보내는 대신 void setRotation(int x, int y, int z)을보고 싶습니다. 마찬가지로 클래스의 이름을 Camera으로 지정하고 LuaCamera 대신 출력으로 지정합니다.

클래스의 이름을 바꾸고 사용하지 않는 함수를 만들 수 있다는 것을 알았지 만, 내 프로그램에 루아 함수가 너무 많아서 접근 방법이 좋지 않습니다.

아이디어가 있으십니까?

+0

: 비슷한 솔루션을 찾고 될 수있는 사람들을위한

, 여기에 파이썬 파일에 소스입니다. "확장 된"형식의 문서를 문서화하고 이름에서 Lua 참조를 제거 하시겠습니까? – BobMorane

+0

예. lua 사용법을 C++ 코드 –

+0

에 문서화해야합니다. 루아 사용법을 포장 한 다음 래퍼에 주석을 달아 주겠습니까? 코드를 수정할 수 없다면 ... – 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();