-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple script to fill placeholders in docs
- Loading branch information
1 parent
5844aa5
commit 4d336c0
Showing
6 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
site_name: Meggie | ||
site_url: https://cibr-jyu.github.io/meggie | ||
docs_dir: docs_updated | ||
|
||
nav: | ||
- Home: index.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import sys | ||
|
||
docs_dir = sys.argv[1] | ||
|
||
def list_files(directory): | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
yield os.path.join(root, file) | ||
|
||
if __name__ == '__main__': | ||
|
||
# parse version from setup.py | ||
with open("setup.py", "r") as f: | ||
lines = f.readlines() | ||
|
||
version = [ | ||
line.split("=")[1].split(",")[0].strip("'") for line in lines if "version" in line | ||
][0] | ||
|
||
# Search and replace the version in the md file | ||
for file_path in list_files(docs_dir): | ||
if not file_path.endswith('.md'): | ||
continue | ||
|
||
# Read the contents of the file | ||
with open(file_path, 'r') as f: | ||
file_contents = f.read() | ||
|
||
# Replace '{{VERSION}}' with the actual version | ||
file_contents = file_contents.replace('{{VERSION}}', version) | ||
|
||
# Write the modified contents back to the file | ||
with open(file_path, 'w') as f: | ||
f.write(file_contents) | ||
|
||
print("Updated the docs successfully.") |