Skip to content

script to make markdown files #665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _tutorials/add-license-coc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Add a License and Code of Conduct to your python package"
excerpt: "Learn how to add a LICENSE and CODE_OF_CONDUCT file to your Python package. This lesson covers choosing a permissive license, placing key files for visibility on GitHub and PyPI, and adopting the Contributor Covenant to support an inclusive community."
link: https://www.pyopensci.org/python-package-guide/tutorials/add-license-coc.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/add-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Add a README file to your Python package"
excerpt: "Learn how to create a clear, effective README file for your Python package. This lesson covers what to include, why each section matters, and how a well-structured README improves usability and discoverability on GitHub and PyPI."
link: https://www.pyopensci.org/python-package-guide/tutorials/add-readme.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/command-line-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Command Line Reference Guide"
excerpt: "Learn how to add a command-line interface (CLI) to your Python package using the argparse library. This lesson walks you through creating a CLI entry point so users can run your package directly from the terminal."
link: https://www.pyopensci.org/python-package-guide/tutorials/command-line-reference.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/get-to-know-hatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Get to Know Hatch"
excerpt: "Get started with Hatch, a modern Python packaging tool. This lesson introduces Hatch’s features and shows how it simplifies environment management, project scaffolding, and building your package."
link: https://www.pyopensci.org/python-package-guide/tutorials/get-to-know-hatch.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/installable-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Make your Python code installable so it can be used across projects"
excerpt: "Learn how to make your code installable as a Python package using Hatch. This lesson walks you through structuring your code and configuring pyproject.toml so others can easily install and use your package."
link: https://www.pyopensci.org/python-package-guide/tutorials/installable-code.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Python packaging 101"
excerpt: "This page outlines the key steps to create, document, and share a high-quality scientific Python package. Here you will also get an overview of the pyOpenSci packaging guide and what you’ll learn."
link: https://www.pyopensci.org/python-package-guide/tutorials/intro.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/publish-conda-forge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Publish your Python package that is on PyPI to conda-forge"
excerpt: "Learn how to publish your Python package on conda-forge to make it easily installable with conda. This lesson covers the submission process, metadata requirements, and maintaining your feedstock."
link: https://www.pyopensci.org/python-package-guide/tutorials/publish-conda-forge.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/publish-pypi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Publish your Python package to PyPI"
excerpt: "Learn how to publish your Python package on PyPI so others can install it using pip. This lesson covers building your package, creating a PyPI account, and uploading your distribution files."
link: https://www.pyopensci.org/python-package-guide/tutorials/publish-pypi.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/pyproject-toml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Make your Python package PyPI ready - pyproject.toml"
excerpt: "The pyproject.toml file is the central configuration file for building and packaging Python projects. This lesson explains key sections like name, version, dependencies, and how they support packaging and distribution. You’ll learn how to set up this file to ensure your package is ready for publishing."
link: https://www.pyopensci.org/python-package-guide/tutorials/pyproject-toml.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
7 changes: 7 additions & 0 deletions _tutorials/setup-py-to-pyproject-toml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Using Hatch to Migrate setup.py to a pyproject.toml"
excerpt: "If you’re creating a pure Python project, pyproject.toml is preferred over setup.py for packaging and configuration. Learn how to migrate from the older setup.py format to the modern pyproject.toml file. This lesson walks you through updating your package metadata and build settings to align with current Python packaging standards."
link: https://www.pyopensci.org/python-package-guide/tutorials/setup-py-to-pyproject-toml.html
btn_label: View Tutorial
btn_class: btn--success btn--large
---
54 changes: 54 additions & 0 deletions scripts/make-tutorials-md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import requests
import xml.etree.ElementTree as ET
from urllib.parse import urlparse
from pathlib import Path

# Configuration
RSS_FEED_URL = "https://www.pyopensci.org/python-package-guide/tutorials.rss"
OUTPUT_DIR = Path("_tutorials")
OUTPUT_DIR.mkdir(exist_ok=True)


def slug_from_url(url):
"""Extract filename from URL and remove `.html`"""
return Path(urlparse(url).path).stem


def create_markdown_file(title, excerpt, link):
slug = slug_from_url(link)
filename = OUTPUT_DIR / f"{slug}.md"

content = f"""---
title: "{title.strip()}"
excerpt: "{excerpt.strip()}"
link: {link}
btn_label: View Tutorial
btn_class: btn--success btn--large
---
"""
filename.write_text(content, encoding="utf-8")
print(f"✅ Created: {filename}")


def main():
print("🔍 Fetching RSS feed...")
resp = requests.get(RSS_FEED_URL)
resp.raise_for_status()

root = ET.fromstring(resp.content)
items = root.findall(".//item")

for item in items:
title = item.findtext("title")
link = item.findtext("link")
excerpt = item.findtext("description")

if title and link and excerpt:
create_markdown_file(title, excerpt, link)

print("🎉 All tutorials processed!")


if __name__ == "__main__":
main()
Loading