diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index 4029e1fed2..36d07da35c 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -43,6 +43,7 @@ jobs: check: ["doctest", "linkcheck"] env: SPHINX_MOCK_REQUIREMENTS: 0 + FAST_DOCS_DEV: 1 steps: - uses: actions/checkout@v3 with: @@ -106,6 +107,8 @@ jobs: fail-fast: false matrix: pkg-name: ["app", "fabric", "pytorch"] + env: + FAST_DOCS_DEV: 0 steps: - uses: actions/checkout@v3 with: diff --git a/docs/README.md b/docs/README.md index d59458b5a5..a2bef27d1c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -64,10 +64,10 @@ To speed this up, enable this flag in before building docs: ```bash # builds notebooks which is slow -export PL_FAST_DOCS_DEV=0 +export FAST_DOCS_DEV=0 # fast notebook build which is fast -export PL_FAST_DOCS_DEV=1 +export FAST_DOCS_DEV=1 ``` ## docs CSS/theme diff --git a/docs/rtfd-build.sh b/docs/rtfd-build.sh index edfc5b3947..c70b440794 100644 --- a/docs/rtfd-build.sh +++ b/docs/rtfd-build.sh @@ -3,7 +3,7 @@ if ! [ $READTHEDOCS_VERSION == "latest" -o $READTHEDOCS_VERSION == "stable" ]; then cd ./docs/source-pytorch ; - export PL_FAST_DOCS_DEV=1 ; + export FAST_DOCS_DEV=1 ; make html --jobs $(nproc) ; ls -lh ../build else diff --git a/docs/source-app/conf.py b/docs/source-app/conf.py index c74f7547af..7da8b69864 100644 --- a/docs/source-app/conf.py +++ b/docs/source-app/conf.py @@ -25,7 +25,8 @@ _PATH_HERE = os.path.abspath(os.path.dirname(__file__)) _PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", "..")) sys.path.insert(0, os.path.abspath(_PATH_ROOT)) -SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) +_SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) +_FAST_DOCS_DEV = int(os.environ.get("FAST_DOCS_DEV", True)) # -- Project information ----------------------------------------------------- @@ -46,10 +47,10 @@ github_repo = project # -- Project documents ------------------------------------------------------- - -fetch_external_assets( - docs_folder=_PATH_HERE, assets_folder="_static/fetched-s3-assets", retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+" -) +if not _FAST_DOCS_DEV: + fetch_external_assets( + docs_folder=_PATH_HERE, assets_folder="_static/fetched-s3-assets", retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+" + ) # -- General configuration --------------------------------------------------- @@ -303,7 +304,7 @@ PACKAGE_MAPPING = { "PyYAML": "yaml", } MOCK_PACKAGES = [] -if SPHINX_MOCK_REQUIREMENTS: +if _SPHINX_MOCK_REQUIREMENTS: # mock also base packages when we are on RTD since we don't install them there MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt")) MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES] diff --git a/docs/source-fabric/conf.py b/docs/source-fabric/conf.py index d8b88d435b..0e96c827c5 100644 --- a/docs/source-fabric/conf.py +++ b/docs/source-fabric/conf.py @@ -25,7 +25,8 @@ _PATH_HERE = os.path.abspath(os.path.dirname(__file__)) _PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", "..")) sys.path.insert(0, os.path.abspath(_PATH_ROOT)) -SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) +_SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) +_FAST_DOCS_DEV = int(os.environ.get("FAST_DOCS_DEV", True)) # -- Project information ----------------------------------------------------- @@ -46,11 +47,12 @@ github_repo = project # -- Project documents ------------------------------------------------------- -fetch_external_assets( - docs_folder=_PATH_HERE, - assets_folder="_static/fetched-s3-assets", - retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+", -) +if not _FAST_DOCS_DEV: + fetch_external_assets( + docs_folder=_PATH_HERE, + assets_folder="_static/fetched-s3-assets", + retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+", + ) # -- General configuration --------------------------------------------------- @@ -286,7 +288,7 @@ PACKAGE_MAPPING = { "PyYAML": "yaml", } MOCK_PACKAGES = [] -if SPHINX_MOCK_REQUIREMENTS: +if _SPHINX_MOCK_REQUIREMENTS: # mock also base packages when we are on RTD since we don't install them there MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt")) MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES] diff --git a/docs/source-pytorch/conf.py b/docs/source-pytorch/conf.py index d2d370e77e..c9b5c31e9c 100644 --- a/docs/source-pytorch/conf.py +++ b/docs/source-pytorch/conf.py @@ -27,7 +27,8 @@ import lightning # ----------------------- # VARIABLES WHEN WORKING ON DOCS... MAKE THIS TRUE TO BUILD FASTER # ----------------------- -_PL_FAST_DOCS_DEV = bool(int(os.getenv("PL_FAST_DOCS_DEV", 0))) +_SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", 1)) +_FAST_DOCS_DEV = bool(int(os.getenv("FAST_DOCS_DEV", 0))) # ----------------------- # BUILD stuff @@ -36,6 +37,7 @@ _PATH_HERE = os.path.abspath(os.path.dirname(__file__)) _PATH_ROOT = os.path.join(_PATH_HERE, "..", "..") _PATH_RAW_NB = os.path.join(_PATH_ROOT, "_notebooks") _SHOULD_COPY_NOTEBOOKS = True +_FOLDER_GENERATED = "generated" def _load_py_module(name: str, location: str) -> ModuleType: @@ -53,8 +55,6 @@ else: _SHOULD_COPY_NOTEBOOKS = False warnings.warn("To build the code, please run: `git submodule update --init --recursive`", stacklevel=2) -FOLDER_GENERATED = "generated" -SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) # -- Project documents ------------------------------------------------------- @@ -80,14 +80,14 @@ if _SHOULD_COPY_NOTEBOOKS: os.remove(file) -os.makedirs(os.path.join(_PATH_HERE, FOLDER_GENERATED), exist_ok=True) +os.makedirs(os.path.join(_PATH_HERE, _FOLDER_GENERATED), exist_ok=True) # copy all documents from GH templates like contribution guide for md in glob.glob(os.path.join(_PATH_ROOT, ".github", "*.md")): - shutil.copy(md, os.path.join(_PATH_HERE, FOLDER_GENERATED, os.path.basename(md))) + shutil.copy(md, os.path.join(_PATH_HERE, _FOLDER_GENERATED, os.path.basename(md))) # copy also the changelog _transform_changelog( os.path.join(_PATH_ROOT, "src", "lightning", "fabric", "CHANGELOG.md"), - os.path.join(_PATH_HERE, FOLDER_GENERATED, "CHANGELOG.md"), + os.path.join(_PATH_HERE, _FOLDER_GENERATED, "CHANGELOG.md"), ) @@ -97,7 +97,7 @@ assist_local.AssistantCLI.pull_docs_files( checkout="tags/1.0.0", ) -if not _PL_FAST_DOCS_DEV: +if not _FAST_DOCS_DEV: fetch_external_assets( docs_folder=_PATH_HERE, assets_folder="_static/fetched-s3-assets", @@ -196,11 +196,11 @@ language = "en" # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [ - f"{FOLDER_GENERATED}/PULL_REQUEST_TEMPLATE.md", + f"{_FOLDER_GENERATED}/PULL_REQUEST_TEMPLATE.md", "notebooks/sample-template*", ] -if _PL_FAST_DOCS_DEV: +if _FAST_DOCS_DEV: exclude_patterns.append("notebooks/*") exclude_patterns.append("tutorials.rst") @@ -372,7 +372,7 @@ PACKAGE_MAPPING = { "hydra-core": "hydra", } MOCK_PACKAGES = [] -if SPHINX_MOCK_REQUIREMENTS: +if _SPHINX_MOCK_REQUIREMENTS: _path_require = lambda fname: os.path.join(_PATH_ROOT, "requirements", "pytorch", fname) # mock also base packages when we are on RTD since we don't install them there MOCK_PACKAGES += package_list_from_file(_path_require("base.txt"))