gen_index.py 949 字节
Newer Older
T
Tink_Y 已提交
1 2 3 4 5 6 7 8 9 10 11 12
import os.path, time
import exceptions
import glob
import os
if __name__ == '__main__':
    
    file_object = open('index_cn.rst', 'w')
    file_object.write('''=============
API Reference
=============

..  toctree::
H
Hao Wang 已提交
13
    :maxdepth: 1
T
Tink_Y 已提交
14 15

''')
16
    file_object.write('    ../api_guides/index_cn.rst'+'\n')
T
tianshuo78520a 已提交
17 18 19 20 21 22 23 24 25 26 27 28

    file_names = []
    file_names = glob.glob("*.rst")
    
    for file_name in sorted(file_names):
        with open(file_name, 'r')as f:
            for i in range(2):
                line = f.readline().strip()
                if line.find('paddle.') != -1:
                    file_object.write('    '+file_name + "\n")
                    file_names.remove(file_name)

T
Tink_Y 已提交
29
    file_object.write('    fluid_cn.rst'+'\n')
T
tianshuo78520a 已提交
30
    for file_name in sorted(file_names):
31
        if file_name != 'index.rst' and file_name != 'index_cn.rst' and file_name != 'fluid_cn.rst':
T
Tink_Y 已提交
32 33
            file_object.write('    '+file_name + "\n")
    file_object.close( )