diff --git a/docs/source/sitemap.py b/docs/sitemap.py similarity index 64% rename from docs/source/sitemap.py rename to docs/sitemap.py index b4d24c6a..87c27849 100644 --- a/docs/source/sitemap.py +++ b/docs/sitemap.py @@ -18,17 +18,16 @@ import datetime import os -import re canonical = "https://docs.pyrogram.org/" dirs = { - "start": ("weekly", 0.9), - "resources": ("weekly", 0.8), - "pyrogram": ("weekly", 0.8), - "functions": ("monthly", 0.7), - "types": ("monthly", 0.7), - "errors": ("weekly", 0.6) + ".": ("weekly", 1.0), + "intro": ("weekly", 0.8), + "start": ("weekly", 0.8), + "api": ("weekly", 0.6), + "topics": ("weekly", 0.6), + "telegram": ("weekly", 0.4) } @@ -37,10 +36,10 @@ def now(): with open("sitemap.xml", "w") as f: - f.write("\n") - f.write("\n") + f.write('\n') + f.write('\n') - urls = [(canonical, now(), "weekly", 1.0)] + urls = [] def search(path): @@ -48,14 +47,27 @@ with open("sitemap.xml", "w") as f: for j in os.listdir(path): search("{}/{}".format(path, j)) except NotADirectoryError: - d = path.split("/")[0] - path = "{}/{}".format(canonical, path.split(".")[0]) - path = re.sub("^(.+)/index$", "\g<1>", path) - urls.append((path, now(), dirs[d][0], dirs[d][1])) + if not path.endswith(".rst"): + return + + path = path.split("/")[1:] + + if path[0].endswith(".rst"): + folder = "." + else: + folder = path[0] + + path = "{}{}".format(canonical, "/".join(path))[:-len(".rst")] + + if path.endswith("index"): + path = path[:-len("index")] + + urls.append((path, now(), *dirs[folder])) - for i in dirs.keys(): - search(i) + search("source") + + urls.sort(key=lambda x: x[3], reverse=True) for i in urls: f.write(" \n")