forked from docs/doc-exports
do not replace existing doc "index" file
Reviewed-by: gtema <artem.goncharov@gmail.com> Co-authored-by: Goncharov, Artem <artem.goncharov@t-systems.com> Co-committed-by: Goncharov, Artem <artem.goncharov@t-systems.com>
This commit is contained in:
parent
1bec551697
commit
66988fd5d1
@ -447,7 +447,28 @@ class OTCDocConvertor:
|
|||||||
title = curr['title']
|
title = curr['title']
|
||||||
page_label = curr['uri'].replace(".html", "").lower()
|
page_label = curr['uri'].replace(".html", "").lower()
|
||||||
path = self.get_target_path(curr['code'], metadata_by_code)
|
path = self.get_target_path(curr['code'], metadata_by_code)
|
||||||
|
|
||||||
|
p = pathlib.Path(dest, f"{path}.rst")
|
||||||
|
if p.exists():
|
||||||
|
logging.warning(
|
||||||
|
f"{p.resolve()} is renamed into {path}/index.rst"
|
||||||
|
)
|
||||||
|
# Update existing index file
|
||||||
|
p.rename(pathlib.Path(dest, f"{path}/index.rst"))
|
||||||
|
with open(pathlib.Path(dest, path, "index.rst"), "a") as index:
|
||||||
|
index.write('\n')
|
||||||
|
index.write('.. toctree::\n')
|
||||||
|
index.write(' :maxdepth: 1\n')
|
||||||
|
index.write(' :hidden: \n\n')
|
||||||
|
for child in v:
|
||||||
|
new_name = child['new_name']
|
||||||
|
if child['code'] in tree:
|
||||||
|
# If this is folder - add /index
|
||||||
|
new_name = new_name + '/index'
|
||||||
|
index.write(f" {new_name}\n")
|
||||||
|
else:
|
||||||
with open(pathlib.Path(dest, path, "index.rst"), "w") as index:
|
with open(pathlib.Path(dest, path, "index.rst"), "w") as index:
|
||||||
|
# New index file
|
||||||
if page_label:
|
if page_label:
|
||||||
index.write(f".. _{page_label}:\n\n")
|
index.write(f".. _{page_label}:\n\n")
|
||||||
index.write('=' * (len(title)) + '\n')
|
index.write('=' * (len(title)) + '\n')
|
||||||
@ -462,14 +483,6 @@ class OTCDocConvertor:
|
|||||||
# If this is folder - add /index
|
# If this is folder - add /index
|
||||||
new_name = new_name + '/index'
|
new_name = new_name + '/index'
|
||||||
index.write(f" {new_name}\n")
|
index.write(f" {new_name}\n")
|
||||||
|
|
||||||
p = pathlib.Path(dest, f"{path}.rst")
|
|
||||||
if p.exists():
|
|
||||||
logging.warning(
|
|
||||||
f"{p.resolve()} is removed in favour"
|
|
||||||
f" of result/{path}/index.rst")
|
|
||||||
p.unlink()
|
|
||||||
|
|
||||||
# Copy used images
|
# Copy used images
|
||||||
if len(self.doc_images) > 0:
|
if len(self.doc_images) > 0:
|
||||||
logging.debug("Processing images...")
|
logging.debug("Processing images...")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user