Skip to content

Commit

Permalink
Gitbook (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
iskay authored Dec 19, 2024
1 parent 0e84a6b commit 0947e62
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 29 deletions.
29 changes: 28 additions & 1 deletion scripts/gen-tools-md.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ def remove_existing_markdown_files(base_dir, gitbook_dir, subdirs):
shutil.rmtree(md_dir)
os.makedirs(md_dir, exist_ok=True)

def generate_summary_file(base_dir, gitbook_dir, subdirs, resources_links):
"""Generate the SUMMARY.md file."""
summary_path = os.path.join(base_dir, gitbook_dir, "SUMMARY.md")
summary_content = "# Summary\n\n## About\n\n* [Home](./README.md)\n* [FAQ](./faq.md)\n\n## Resources\n"

for subdir, links in resources_links.items():
summary_content += f"* [{subdir.title()} Resources](./{subdir}/README.md)\n"
for title, path in links:
summary_content += f" * [{title}](./{path})\n"

try:
with open(summary_path, "w") as summary_file:
summary_file.write(summary_content)
print(f"Generated {summary_path}")
except IOError as e:
print(f"Error writing to {summary_path}: {e}")

def generate_markdown_files(files_keys_exclude):
"""
Generate markdown files from the Json input files.
Expand All @@ -18,10 +35,13 @@ def generate_markdown_files(files_keys_exclude):
subdirs = ["mainnet", "testnet"]
base_dir = "user-and-dev-tools"
gitbook_dir = "gitbook"
base_url = "https://luminara-namada.gitbook.io/namada-ecosystem/resources"

# Remove any existing markdown files
remove_existing_markdown_files(base_dir, gitbook_dir, subdirs)

resources_links = {subdir: [] for subdir in subdirs}

for subdir in subdirs:
json_dir = os.path.join(base_dir, subdir)
md_dir = os.path.join(base_dir, gitbook_dir, subdir)
Expand Down Expand Up @@ -71,7 +91,11 @@ def generate_markdown_files(files_keys_exclude):
print(f"Generated {md_file_path}")

# Add link to README content
readme_content += f"- [{md_file_name.replace('.md', '').title()}]({md_file_name})\n"
link = f"{base_url}/{subdir}/{md_file_name.replace('.md', '')}"
readme_content += f"- [{md_file_name.replace('.md', '').title()}]({link})\n"

# Add link to resources for SUMMARY.md
resources_links[subdir].append((md_file_name.replace('.md', '').title(), f"{subdir}/{md_file_name}"))
except IOError as e:
print(f"Error writing to {md_file_path}: {e}")

Expand All @@ -84,6 +108,9 @@ def generate_markdown_files(files_keys_exclude):
except IOError as e:
print(f"Error writing to {readme_file_path}: {e}")

# Generate the SUMMARY.md file
generate_summary_file(base_dir, gitbook_dir, subdirs, resources_links)

if __name__ == "__main__":
# Load the list of files and keys to exclude from the markdown
script_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
6 changes: 1 addition & 5 deletions user-and-dev-tools/gitbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ Here, you can find an up-to-date registry of:

**Are you hosting infra or some other tool?** Get listed here by making a PR to this repo! Just find and update the relevant json file in the [user-and-dev-tools](https://github.com/Luminara-Hub/namada-ecosystem/tree/main/user-and-dev-tools) directory with your info.

### Quick Links
- [Mainnet Resources](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet)
- [Testnet Resources](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet)
- [FAQ](https://luminara-namada.gitbook.io/namada-ecosystem/about/faq)

---

These docs are publicly hosted on GitBook at https://luminara-namada.gitbook.io/namada-ecosystem.

Suggest improvements by creating an issue or pull request at the [namada-ecosystem](https://github.com/Luminara-Hub/namada-ecosystem) repo.
23 changes: 23 additions & 0 deletions user-and-dev-tools/gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,28 @@

## Resources
* [Mainnet Resources](./mainnet/README.md)
* [Ibc-Relayers](./mainnet/ibc-relayers.md)
* [Explorers](./mainnet/explorers.md)
* [Namada-Indexers](./mainnet/namada-indexers.md)
* [Seeds](./mainnet/seeds.md)
* [Monitoring-And-Dashboards](./mainnet/monitoring-and-dashboards.md)
* [Snapshots](./mainnet/snapshots.md)
* [Tooling-And-Scripts](./mainnet/tooling-and-scripts.md)
* [Rpc](./mainnet/rpc.md)
* [Peers](./mainnet/peers.md)
* [Masp-Indexers](./mainnet/masp-indexers.md)
* [Signers-Wallets](./mainnet/signers-wallets.md)
* [Interfaces](./mainnet/interfaces.md)
* [Testnet Resources](./testnet/README.md)
* [Ibc-Relayers](./testnet/ibc-relayers.md)
* [Explorers](./testnet/explorers.md)
* [Namada-Indexers](./testnet/namada-indexers.md)
* [Seeds](./testnet/seeds.md)
* [Monitoring-And-Dashboards](./testnet/monitoring-and-dashboards.md)
* [Snapshots](./testnet/snapshots.md)
* [Tooling-And-Scripts](./testnet/tooling-and-scripts.md)
* [Rpc](./testnet/rpc.md)
* [Peers](./testnet/peers.md)
* [Masp-Indexers](./testnet/masp-indexers.md)
* [Signers-Wallets](./testnet/signers-wallets.md)
* [Interfaces](./testnet/interfaces.md)
22 changes: 11 additions & 11 deletions user-and-dev-tools/gitbook/mainnet/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Mainnet Resources

- [Ibc-Relayers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/ibc-relayers.md)
- [Explorers](explorers.md)
- [Namada-Indexers](namada-indexers.md)
- [Seeds](seeds/)
- [Monitoring-And-Dashboards](monitoring-and-dashboards.md)
- [Ibc-Relayers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/ibc-relayers)
- [Explorers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/explorers)
- [Namada-Indexers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/namada-indexers)
- [Seeds](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/seeds)
- [Monitoring-And-Dashboards](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/monitoring-and-dashboards)
- [Snapshots](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/snapshots)
- [Tooling-And-Scripts](tooling-and-scripts.md)
- [Rpc](rpc.md)
- [Peers](peers.md)
- [Masp-Indexers](masp-indexers.md)
- [Signers-Wallets](signers-wallets.md)
- [Interfaces](interfaces.md)
- [Tooling-And-Scripts](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/tooling-and-scripts)
- [Rpc](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/rpc)
- [Peers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/peers)
- [Masp-Indexers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/masp-indexers)
- [Signers-Wallets](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/signers-wallets)
- [Interfaces](https://luminara-namada.gitbook.io/namada-ecosystem/resources/mainnet/interfaces)
24 changes: 12 additions & 12 deletions user-and-dev-tools/gitbook/testnet/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Testnet Resources

- [Ibc-Relayers](ibc-relayers.md)
- [Explorers](explorers.md)
- [Namada-Indexers](namada-indexers.md)
- [Seeds](seeds.md)
- [Monitoring-And-Dashboards](monitoring-and-dashboards.md)
- [Snapshots](snapshots.md)
- [Tooling-And-Scripts](tooling-and-scripts.md)
- [Rpc](rpc.md)
- [Peers](peers.md)
- [Masp-Indexers](masp-indexers.md)
- [Signers-Wallets](signers-wallets.md)
- [Interfaces](interfaces.md)
- [Ibc-Relayers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/ibc-relayers)
- [Explorers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/explorers)
- [Namada-Indexers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/namada-indexers)
- [Seeds](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/seeds)
- [Monitoring-And-Dashboards](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/monitoring-and-dashboards)
- [Snapshots](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/snapshots)
- [Tooling-And-Scripts](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/tooling-and-scripts)
- [Rpc](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/rpc)
- [Peers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/peers)
- [Masp-Indexers](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/masp-indexers)
- [Signers-Wallets](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/signers-wallets)
- [Interfaces](https://luminara-namada.gitbook.io/namada-ecosystem/resources/testnet/interfaces)

0 comments on commit 0947e62

Please sign in to comment.