dae/hack/ci/config-doc-generator.py
Kevin Yu e39ec7fc05
refactor(/docs): rework documentation structure layout (#179)
* refactor(/docs): rework documentation structure layout

* refactor(/docs): update file reference paths

* feat(/docs): add English version of other-proxy-protocol.md

* refacotr: move docs/templates/ docs/sync/ to hack/

* fix(example.dae|readme): update ref link to adopt new file structure

* refactor: rename other-proxy-protocol.md -> proxy-protocols.md

* docs(readme): add ref to proxy-protocols.md

* feat(/docs): add English version of how-it-works.md

* refactor: rename how-it-works; add nav links

* fix: fix linting errors

* fix: fix linting errors

---------

Co-authored-by: earrmouth <43926351+earrmouth@users.noreply.github.com>
2023-07-09 17:31:47 +08:00

35 lines
845 B
Python

import re
def read_config(filename):
with open(filename, "r") as f:
return "".join(f.readlines())
def replacetext(src_file, dest_file, search_text, replace_text):
with open(src_file, "r+") as src:
src_file = src.read() # Read
src.close()
with open(dest_file, "w") as dest:
dest_file = re.sub(search_text, replace_text, src_file) # Replace
dest.seek(0) # Setting the position to the top of the page to insert data
dest.write(dest_file) # Write
dest.close()
def main():
search_text = "<!-- TEXT REPLACE -->"
replace_text = read_config("example.dae")
replacetext(
"hack/templates/example-config.md",
"hack/sync/example-config.md",
search_text,
replace_text,
)
if __name__ == "__main__":
main()