More style fixes in documentation scripts

This commit is contained in:
Ivan Blinkov 2018-02-21 21:28:27 +03:00
parent f83bf6bcd5
commit 7e902c0bd6
3 changed files with 40 additions and 37 deletions

View File

@ -14,7 +14,6 @@
# - For not http-links without anchor script logs an error and cuts them from the resulting single-page document. # - For not http-links without anchor script logs an error and cuts them from the resulting single-page document.
import codecs import codecs
import sys import sys
import re import re

View File

@ -4,6 +4,7 @@
SOURCES_TREE = 'ru' SOURCES_TREE = 'ru'
from os import walk from os import walk
def get_header(filepath): def get_header(filepath):
f = open(filepath) f = open(filepath)
header = '' header = ''
@ -23,13 +24,16 @@ md_links_file = open("links_for_md.txt","w")
for (dirpath, dirnames, filenames) in walk(SOURCES_TREE): for (dirpath, dirnames, filenames) in walk(SOURCES_TREE):
for filename in filenames: for filename in filenames:
if '.md' not in filename: continue if '.md' not in filename:
continue
header = get_header(dirpath + '/' + filename) header = get_header(dirpath + '/' + filename)
path = dirpath.replace('docs/', '') + '/' + filename path = dirpath.replace('docs/', '') + '/' + filename
if filename == 'index.md': pages_file.write("- '" + header + "': " + "'" + path + "'\n") if filename == 'index.md':
else: pages_file.write(" - '" + header + "': " + "'" + path + "'\n") pages_file.write("- '" + header + "': " + "'" + path + "'\n")
else:
pages_file.write(" - '" + header + "': " + "'" + path + "'\n")
md_links_file.write("[" + header + "](" + path + ")\n") md_links_file.write("[" + header + "](" + path + ")\n")

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Gets all the files in SOURCES_TREE directory, shows all level headers for each file and skip or process files by user's selection. # Gets all the files in SOURCES_TREE directory, shows all level headers
# for each file and skip or process files by user's selection.
import os import os
@ -18,7 +19,6 @@ for (dirpath, dirnames, filenames) in os.walk(SOURCES_TREE):
content = f.readlines() content = f.readlines()
f.close() f.close()
# Showing headers structure in md-file # Showing headers structure in md-file
count_lines = 0 count_lines = 0
for l in content: for l in content: