Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

馃摑 Update details syntax with new pymdown extensions format - #713

#713
Merged
tiangolo merged 1 commit into
mainfastapi/sqlmodel:mainfrom
detailsfastapi/sqlmodel:detailsCopy head branch name to clipboard
Nov 28, 2023
Merged

馃摑 Update details syntax with new pymdown extensions format#713
tiangolo merged 1 commit into
mainfastapi/sqlmodel:mainfrom
detailsfastapi/sqlmodel:detailsCopy head branch name to clipboard

Conversation

@tiangolo

@tiangolo tiangolo commented Nov 28, 2023

Copy link
Copy Markdown
Member

馃摑 Update details syntax with new pymdown extensions format

I wrote a script to automatically update the details blocks:

import os
import re
from pathlib import Path

base_dir = Path(__file__).parent.parent

def update_details():
    os.chdir(base_dir)
    md_files = list(Path("docs").glob("**/*.md"))
    # md_files = [Path("docs/advanced/decimal.md")]
    re_str = r"<summary>((\n|.)*)</summary>"
    # md_file = md_files[25]
    for md_file in md_files:
        content = md_file.read_text()
        new_content = content
        all_starts = re.finditer("<details>", content)
        all_ends = re.finditer("</details>", content)
        for start, end in zip(all_starts, all_ends):
            sub_content = content[start.start() : end.end()]
            m = re.search(re_str, sub_content)
            assert m
            summary = m.group(1).strip()
            sub_content_internal = content[start.end() : end.start()].strip()
            sub_content_no_summary = re.sub(re_str, "", sub_content_internal).strip()
            new_sub_content = f"/// details | {summary}\n\n{sub_content_no_summary}\n\n///"
            new_content = new_content.replace(sub_content, new_sub_content)

        md_file.write_text(new_content)

if __name__ == "__main__":
    update_details()

@tiangolo tiangolo added the internal Internal changes label Nov 28, 2023
@github-actions

Copy link
Copy Markdown
Contributor

馃摑 Docs preview for commit 34a85e9 at: https://ee7298be.sqlmodel.pages.dev

@tiangolo
tiangolo merged commit 799d0aa into main Nov 28, 2023
@tiangolo
tiangolo deleted the details branch November 28, 2023 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.