-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerating_readme.py
57 lines (48 loc) · 2.02 KB
/
generating_readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# SOURCE: https://medium.com/pythoneers/10-mindblowing-automation-scripts-you-need-to-try-using-python-8bd935f88125
import os
def generate_markdown_file():
# Prompting user for inputs
repository_name = input("\n Enter the name of your GitHub repository: ")
subrepository = input("\n Enter the name of your GitHub subrepository: ")
link = input("\n Enter the link of the GitHub repository: ")
project_description = input("Enter a short description of your project: ")
installation_instructions = input("Enter installation instructions for your project: ")
usage_instructions = input("Enter usage instructions for your project: ")
contributors = input("Enter the contributors to your project (separated by commas): ")
# Generating list of contents
contents_list = generate_contents_list(subrepository)
# Generating Markdown content
markdown_content = f"""# {repository_name}
{project_description}
## Table of Contents
- [Installation](#installation)
- [Contents](#contents)
- [Usage](#usage)
- [Contributors](#contributors)
- [GitHub Repository](#github-repository)
## Installation
{installation_instructions}
## Contents
{contents_list}
## Usage
{usage_instructions}
## Contributors
{contributors}
## GitHub Repository
[Link to GitHub repository]({link})
"""
# Writing content to Markdown file
markdown_file_name = "README.md"
with open(markdown_file_name, "w") as markdown_file:
markdown_file.write(markdown_content)
print(f"Markdown file '{markdown_file_name}' generated successfully!")
def generate_contents_list(subrepository):
contents_list = ""
folder_path = os.path.join(".", subrepository)
for item in os.listdir(folder_path):
item_path = os.path.join(folder_path, item) # Get the full path of the item within the folder
if os.path.isdir(item_path) or os.path.isfile(item_path): # Check if the item is a directory or a file
contents_list += f"- {item}\n"
return contents_list
if __name__ == "__main__":
generate_markdown_file()