Skip to content

Commit

Permalink
customize readme copy
Browse files Browse the repository at this point in the history
  • Loading branch information
bhagyasharma committed Jul 2, 2024
1 parent 8f70285 commit 42c4635
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Our SDK is designed to supercharge your API experience and accelerate your time to insight. It enables you to efficiently pull the data you need, analyze it, and visualize your findings.

## Parcl Labs Data Overview
### Parcl Labs Data Overview

The Parcl Labs API provides **instant insights into the U.S. housing market**, delivering data on housing supply, sales, listings, rentals, investor activities, and market trends.

Expand Down
28 changes: 20 additions & 8 deletions scripts/copy_readme.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import os
FRONT_MATTER = "---\ntitle: Python Library\nslug: python-library-1\n---\n\n"


def main():
"""
Copy README.md to README_COPY.md and prepend front matter to the copied file to prepare for readme doc deployment
Create custom README copy that adds front matter and deletes irrelevant fields for readme doc deployment
"""
input_readme = "README.md"
output_file = "README_COPY.md"
os.system(f"cp {input_readme} {output_file}")
with open(input_readme, "r") as file:
readme_lines = file.readlines()

prepend_lines = "---\ntitle: Python Library\nslug: python-library-1\n---\n\n"
with open(output_file, "r+") as file:
content = file.read()
file.seek(0, 0)
file.write(prepend_lines + content)
# remove links
for line in readme_lines:
if line.startswith(("![Logo]", "![GitHub Tag]", "![PyPI - Downloads]")):
readme_lines.remove(line)

# remove irrelavant sections
readme_content = "".join(readme_lines)
count = 0
for section in readme_content.split("\n### "):
if section.startswith("Parcl Labs Data Overview"):
full_section = "\n### " + section
readme_content = readme_content.replace(full_section, "")
count += 1

with open(output_file, "w") as f:
f.write(FRONT_MATTER + readme_content)


if __name__ == "__main__":
Expand Down

0 comments on commit 42c4635

Please sign in to comment.