Skip to content

📝 Cleanup local links in docs#10500

Closed
nilslindemann wants to merge 25 commits intofastapi:masterfrom
nilslindemann:cleanup-links
Closed

📝 Cleanup local links in docs#10500
nilslindemann wants to merge 25 commits intofastapi:masterfrom
nilslindemann:cleanup-links

Conversation

@nilslindemann
Copy link
Contributor

@nilslindemann nilslindemann commented Oct 23, 2023

(I will recreate this in a later PR)

The PR only touches local links to markdowns (links to .pngs and .pys are all good) and does not touch external links.

Aside of fixing broken local links,

  • it makes absolute links relative (no links anymore which start with /)
  • it appends index.md where missing, so that all links either are hash-only in-document links or links with .md in them
  • it removes ./ from start of links

The following patterns can be used to search for these links (and should find nothing with this PR applied):

  • Links without index.md: the regex \]\((?!http)[^)#]*/(#[^#)]+)?\)
  • Absolute links: ](/
  • Links with "./" at the start: ](./

I also fix untranslated #hash-parts in links, so far in es, fr, em. Will add more commits. When the author has not translated the link text, I leave it, instead of guessing.

This script tests if all links are according to the above definitions, and it checks if the path parts of links point to existing files. It does not check if the hash points to an existing heading. After this PR is applied, the script outputs:

> python linkchecker.py 

Each link under /home/nils/FastAPI/fastapi/docs is:

* a https link to an external url
* a well-formed local relative link to a .md / .png / .py

These files are referenced in links but do not exist:
    /home/nils/FastAPI/fastapi/docs/en/docs/advanced/async-sql-databases.md

@tiangolo
Copy link
Member

nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Oct 23, 2023
nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Oct 23, 2023
nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Oct 24, 2023
nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Oct 24, 2023
@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@nilslindemann nilslindemann changed the title Cleanup links 📝 Cleanup local links in docs Oct 31, 2023
@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Nov 1, 2023
nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Nov 2, 2023
nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Nov 2, 2023
nilslindemann pushed a commit to nilslindemann/fastapi that referenced this pull request Nov 3, 2023
@tiangolo
Copy link
Member

@tiangolo
Copy link
Member

tiangolo commented Dec 1, 2023

@nilslindemann nilslindemann deleted the cleanup-links branch January 13, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants