File: check_structure.py

package info (click to toggle)
blender-doc 4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 253,604 kB
  • sloc: python: 13,030; javascript: 322; makefile: 113; sh: 107
file content (46 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# Apache License, Version 2.0

"""
This utility checks the overall structure of the manual:

- Ensures each directory contains an index file.
"""

import sys
import os


# if you want to operate on a subdir, e.g: "render"
SUBDIR = ""
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
ROOT_DIR = os.path.normpath(os.path.join(CURRENT_DIR, "..", ".."))
RST_DIR = os.path.join(ROOT_DIR, "manual", SUBDIR)


def print_title(title, underline="="):
    print(f"\n{title}\n{len(title) * underline}")


# Ensure each directory contains an index file.
def find_subdirs_without_index(root_dir):
    print_title("List of directories missing index.rst:")
    for dirpath, _dirnames, filenames in os.walk(root_dir):
        # Skip the '/manual/images' directory
        if '/manual/images' in dirpath:
            continue

        if 'index.rst' not in filenames:
            print(dirpath)


def main():
    if "--help" in sys.argv:
        print(__doc__)
        sys.exit(0)

    find_subdirs_without_index(RST_DIR)


if __name__ == "__main__":
    main()