Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx Multiversioning #346

Open
wants to merge 287 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
287 commits
Select commit Hold shift + click to select a range
13445c7
wrong jekyll changes reverted
ZergLev Apr 27, 2024
71c45c3
automated local doc builds + cleaning only outdated docs locally + sh…
ZergLev May 2, 2024
52ebe11
removed debug output
ZergLev May 2, 2024
2ae84ef
mistake fixed
ZergLev May 2, 2024
c71a93e
mistake fixed
ZergLev May 2, 2024
d6cbee9
mistake fixed
ZergLev May 2, 2024
b0abfe5
Debug output removed
ZergLev May 2, 2024
f5663eb
Comment fixed
ZergLev May 2, 2024
371e655
Review change
ZergLev May 2, 2024
17ca707
made it an option for conf.py replacement
ZergLev May 2, 2024
9be3858
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev May 2, 2024
21869ed
removed saving branch name without slashes, because it's unused now
ZergLev May 2, 2024
cd6c5b4
Fixed mistake
ZergLev May 2, 2024
9eaa6b5
only updating switcher from master (wouldn't want to break it from an…
ZergLev May 2, 2024
e93c946
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev May 2, 2024
77a6a52
merging dev
ZergLev Sep 27, 2024
daa496c
minor self-review changes
ZergLev Sep 27, 2024
3887383
dependencies mistake fixed + lint
ZergLev Sep 27, 2024
b75c8cc
merge change + mistake fixed
ZergLev Sep 27, 2024
ad05246
testing github workflow (actions/checkout@v4)
ZergLev Sep 27, 2024
fa26ee4
Revert "testing github workflow (actions/checkout@v4)"
ZergLev Sep 27, 2024
07d1eeb
testing workflow
ZergLev Sep 27, 2024
f29d02a
removed customized sphinx-polyversion dependency, it's now relying on…
ZergLev Sep 27, 2024
73602da
testing the fix for detached HEAD in PRs
ZergLev Oct 2, 2024
faaaf4d
Merge branch 'dev' into feat/sphinx_multiversion
ZergLev Oct 2, 2024
1610fcb
testing
ZergLev Oct 2, 2024
ea07d52
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev Oct 2, 2024
bb939fd
testing
ZergLev Oct 2, 2024
26ab914
testing
ZergLev Oct 2, 2024
c3a931b
detached head fix drafted
ZergLev Oct 2, 2024
d5da02f
testing
ZergLev Oct 2, 2024
85ca397
testing
ZergLev Oct 2, 2024
95e0e7d
testing
ZergLev Oct 2, 2024
71c2565
testing artifact saving
ZergLev Oct 2, 2024
652d7c2
more testing
ZergLev Oct 2, 2024
4022111
fixed typo
ZergLev Oct 2, 2024
c203eea
fixed typo
ZergLev Oct 2, 2024
1667bc1
testing
ZergLev Oct 2, 2024
7ad36c6
testing
ZergLev Oct 2, 2024
70d8350
testing
ZergLev Oct 2, 2024
87d7afd
fixed typo
ZergLev Oct 2, 2024
f9d9978
drafted new colab and github links in tutorials
ZergLev Oct 4, 2024
f43edb4
Merge branch 'dev' into feat/sphinx_multiversion
ZergLev Oct 4, 2024
d9b1c9e
testing adding doc_version via conf.py
ZergLev Oct 4, 2024
784fc0c
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev Oct 4, 2024
aa3c320
testing
ZergLev Oct 4, 2024
02a4be5
drafted old docs build in local builds and PRs
ZergLev Oct 4, 2024
8f67549
testing
ZergLev Oct 4, 2024
a4fc074
attempting to fix links
ZergLev Oct 7, 2024
dab2bb9
small changes, testing
ZergLev Oct 7, 2024
2b27597
during non-polyversion build setup is just imported into conf.py from…
ZergLev Oct 7, 2024
751a87b
testing
ZergLev Oct 7, 2024
43de4e6
testing poly build
ZergLev Oct 7, 2024
a30b21e
testing
ZergLev Oct 7, 2024
3b2c772
switched order of setup and link fixing
ZergLev Oct 7, 2024
df027ef
added POLYVERSION_BUILD variable handling in github actions
ZergLev Oct 7, 2024
0d2ac40
fixed small mistake
ZergLev Oct 7, 2024
2f76d66
testing
ZergLev Oct 7, 2024
4175a29
fixed typo + updated tutorial toctree
ZergLev Oct 7, 2024
3bf22d4
testing
ZergLev Oct 7, 2024
9f5fec3
fixed typo
ZergLev Oct 7, 2024
1fcb631
testing no polyversion build
ZergLev Oct 7, 2024
82154ca
fixed typo
ZergLev Oct 7, 2024
a09afba
github workflow will delete all the old versions of docs now, testing
ZergLev Oct 9, 2024
aacca40
fixing an issue, added docs link printout to workflow
ZergLev Oct 9, 2024
64c6930
fixing an issue (conf.py setup needs an empty argument slot)
ZergLev Oct 9, 2024
b5bf331
poly.py partial self-review
ZergLev Oct 9, 2024
a84857d
testing PR docs building
ZergLev Oct 9, 2024
38214b4
not deleting old files for PRs for now
ZergLev Oct 9, 2024
f1edadb
added deleting old docs for PRs
ZergLev Oct 9, 2024
6502a1c
fixing PR outputting into the wrong folder
ZergLev Oct 9, 2024
684599b
fixing workflow's small python script
ZergLev Oct 9, 2024
c475156
fixed typo (fixed recursive directory declaration)
ZergLev Oct 9, 2024
31b752d
fixed PR deploy target directory, testing
ZergLev Oct 9, 2024
64e9375
fixed typo
ZergLev Oct 9, 2024
c6808bb
fixed typo
ZergLev Oct 9, 2024
3fc0dc9
Added comments and some changes during the call
ZergLev Oct 9, 2024
253f85c
mention project template in the getting started section
RLKRo Oct 10, 2024
59687da
added the creation of tag regex for polyversion, plus filtering for '…
ZergLev Oct 11, 2024
3ed732f
testing polyversion tag building
ZergLev Oct 11, 2024
b8dea82
fixed typo in workflow
ZergLev Oct 11, 2024
53ceae5
fixed typo
ZergLev Oct 11, 2024
466675a
testing
ZergLev Oct 11, 2024
bc9e559
fixed mistake
ZergLev Oct 11, 2024
0aa2fc2
testing
ZergLev Oct 11, 2024
fa22f77
fixed typo
ZergLev Oct 11, 2024
bfd7f4e
drafted setup() function import for older versions
ZergLev Oct 11, 2024
95d604b
testing
ZergLev Oct 11, 2024
3061a1c
testing
ZergLev Oct 11, 2024
48156fa
removed setup() usage from builder.py, it's now called from conf.py
ZergLev Oct 11, 2024
5570c3f
fixed typo
ZergLev Oct 11, 2024
1d6fc2f
fixed typo
ZergLev Oct 11, 2024
5ff2d0a
testing
ZergLev Oct 11, 2024
a944f57
Merge branch 'deeppavlov:master' into master
ZergLev Oct 11, 2024
9255c53
testing
ZergLev Oct 11, 2024
7f4a153
building docs only for latest tags in their respective groups
ZergLev Oct 14, 2024
91b3005
adding sphinx-polyversion to poetry dependencies for each build
ZergLev Oct 14, 2024
f1aeceb
changed link_misc_files() to work on Windows pathing too
ZergLev Oct 16, 2024
59ea195
drafted version-dependent links for PRs and local builds (using strin…
ZergLev Oct 16, 2024
6cd25b1
drafted sphinx-polyversion being added to each build (created custom …
ZergLev Oct 16, 2024
8ec6aa4
lint + a few typos fixed
ZergLev Oct 16, 2024
46993c4
changed custom class to include everythin, there has to be a better w…
ZergLev Oct 16, 2024
9da7aa0
fixed imports
ZergLev Oct 16, 2024
cb6c579
fixing imports
ZergLev Oct 16, 2024
648627b
debugging
ZergLev Oct 16, 2024
432ac89
fixed minor mistake
ZergLev Oct 16, 2024
8a13a01
trying to fix setup() import
ZergLev Oct 16, 2024
4dc1197
some comments added during the call
ZergLev Oct 17, 2024
6046a85
custom Poetry class workaround removed, instead pyproject.toml files …
ZergLev Oct 17, 2024
416d9f2
fixing conf.py imports
ZergLev Oct 18, 2024
69fc752
workflow mistake fixed, added a custom polyversion driver for catchin…
ZergLev Oct 18, 2024
520a0b3
attempting simple setup() import in conf.py
ZergLev Oct 18, 2024
a1b26d5
debugging
ZergLev Oct 18, 2024
d8bc882
debugging
ZergLev Oct 18, 2024
a0d33c8
fixed mistake in APIref building
ZergLev Oct 18, 2024
4c86ac6
fixed another mistake in APIref and drawio building
ZergLev Oct 18, 2024
e4c1ca7
fixed another APIref building mistake, debugging
ZergLev Oct 18, 2024
9430993
changed comment
ZergLev Oct 18, 2024
3c5e46c
drafted multiversion example and source links, fixed a mistake in dra…
ZergLev Oct 18, 2024
aaf3346
testing
ZergLev Oct 18, 2024
1925acb
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev Oct 18, 2024
05bdbe4
Revert "testing"
ZergLev Oct 18, 2024
5585c18
drafting configs dict for setup() utils funcs (squash this commit)
ZergLev Oct 23, 2024
a2c0783
lots of comments on how to change the entire PR (squash this commit)
ZergLev Oct 23, 2024
40e62a3
merged laptop's work (squash this commit)
ZergLev Oct 23, 2024
f640188
setup() changed to use a dict of parameters as it's configs
ZergLev Oct 23, 2024
c0db3d2
building the 'latest' version only when necessary to save time
ZergLev Oct 23, 2024
5e5fc18
fixed wrong import
ZergLev Oct 23, 2024
7a694ed
fixed import + formatted (squash this commit)
ZergLev Oct 23, 2024
8c3c6f7
building the 'latest' version only when necessary to save time
ZergLev Oct 23, 2024
c3db9a3
building the 'latest' version only when necessary to save time
ZergLev Oct 23, 2024
d83468c
removed redundant comment
ZergLev Oct 23, 2024
3c13f06
Merge branch 'master' of https://github.com/ZergLev/chatsky
ZergLev Oct 23, 2024
8e06cc2
lint + typo fixed (squash this commit)
ZergLev Oct 23, 2024
29f7759
Merge branch 'master' of https://github.com/ZergLev/chatsky into feat…
ZergLev Oct 23, 2024
853d1de
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev Oct 23, 2024
05a5778
testing no master branch building
ZergLev Oct 23, 2024
823e19d
fixed typo
ZergLev Oct 23, 2024
15c4a7c
updated deps
ZergLev Oct 16, 2024
686349b
local version builds properly, typos fixed
ZergLev Oct 24, 2024
f4a6ec6
setup() is called from builder during polyversion builds again, this …
ZergLev Oct 24, 2024
b19af03
posting v0.8.0 and v0.9.0 buildsto gh-pages, while ignoring warnings
ZergLev Oct 24, 2024
b7becbd
add tmp_docs
RLKRo Oct 25, 2024
7463de7
comments added
ZergLev Oct 28, 2024
1d23af8
Merge branch 'master' of https://github.com/ZergLev/chatsky
ZergLev Oct 28, 2024
e40767b
lint
ZergLev Oct 28, 2024
49b91b7
builder doesn't redefine polyversion's code now, testing
ZergLev Oct 28, 2024
bdc6ae8
reconfigured switcher_json to the recent version of PR
ZergLev Oct 28, 2024
0f52907
fixed circular import (added tags_filter.py file)
ZergLev Oct 28, 2024
75784e1
drafted new 404.html file in gh-pages branch (redirecting from latest…
ZergLev Oct 28, 2024
08da682
added current date showing up (not fully configured yet, testing)
ZergLev Oct 28, 2024
b8eee75
remade workflow and partially version-switcher generator (removing sp…
ZergLev Oct 31, 2024
a53aba1
removing sphinx-polyversion, switching to own Sphinx Multiversioning,…
ZergLev Oct 31, 2024
51265de
restored the rest of the old files
ZergLev Oct 31, 2024
d63587b
testing build
ZergLev Oct 31, 2024
075c736
lint
ZergLev Oct 31, 2024
0e604e3
adding today's date to docs
ZergLev Oct 31, 2024
ab3c864
testing today's date in docs
ZergLev Oct 31, 2024
61d9e8d
changed today's format in conf.py, switcher-gen tag filtering workaro…
ZergLev Nov 1, 2024
b292ad0
added switcher-gen to github workflow
ZergLev Nov 1, 2024
16e903d
changed workflow to update the version switcher file in a different w…
ZergLev Nov 1, 2024
9628ae8
added GitPython to 'docs' dependencies
ZergLev Nov 1, 2024
4e25b1f
poetry.lock updated
ZergLev Nov 1, 2024
376bd1f
moved switcher generation from workflow into setup(), as it makes mor…
ZergLev Nov 1, 2024
759e986
poetrly.lock updated
ZergLev Nov 1, 2024
a7a1e59
testing workflow updating version switcher
ZergLev Nov 1, 2024
2f9976f
debugging workflow updating version switcher
ZergLev Nov 1, 2024
9d9aa9c
debugging workflow updating version switcher
ZergLev Nov 1, 2024
b7c80c4
debugging workflow updating version switcher
ZergLev Nov 1, 2024
0a7f171
testing workflow updating version switcher
ZergLev Nov 1, 2024
1250537
fixed versions being reversed in the version switcher file
ZergLev Nov 1, 2024
73d177c
workflow now triggers with tag pushes
ZergLev Nov 1, 2024
89369ec
notes during the work call, some comments changed
ZergLev Nov 2, 2024
bdc9425
moved version switcher generation to scripts + slightly changed file …
ZergLev Nov 2, 2024
c4e7ff6
refactored version switcher updated, mistake fixed (double index.html…
ZergLev Nov 2, 2024
91354de
added versioning links in .rst files, testing
ZergLev Nov 2, 2024
c1be4fe
changed versioned links to extlinks (except example and source links)…
ZergLev Nov 2, 2024
6f5e9f4
fixed versioned links for example and source links
ZergLev Nov 2, 2024
ade1fa5
work call notes added
ZergLev Nov 5, 2024
0428a26
showing version warning banners for tags and dev only, testing
ZergLev Nov 6, 2024
a91f8f1
returned setup() into a separate file, added start_version to switche…
ZergLev Nov 6, 2024
a3c555d
replaced 'zerglev' with 'deeppavlov'
ZergLev Nov 6, 2024
07c2e40
Merge branch 'dev' into feat/sphinx_multiversion
ZergLev Nov 6, 2024
466cdce
updating version switcher and cleaning docs with github-deploy-action…
ZergLev Nov 8, 2024
ef59767
fixed minor mistake (copying a file into a non-existent directory)
ZergLev Nov 8, 2024
a91a6b7
version warning banner removed
ZergLev Nov 8, 2024
1806dfb
gh-mutex added for github-pages deployment security
ZergLev Nov 8, 2024
31bb42f
parsing GitHub Actions variables now
ZergLev Nov 8, 2024
1d5e296
self-review (changed mostly redundant imports or misleading comments)
ZergLev Nov 8, 2024
71ab8da
fixed mistake (github actions variable usage)
ZergLev Nov 8, 2024
9146de4
fixed github-actions variables parsing
ZergLev Nov 8, 2024
b813b98
fixed github-actions variables parsing
ZergLev Nov 8, 2024
a388219
fixed typo (changed again how github variables are parsed)
ZergLev Nov 8, 2024
9e7d765
showcase build (deeppavlov -> zerglev (for correct version switcher l…
ZergLev Nov 8, 2024
9ddbfc7
added a workflow that generates the version switcher, testing
ZergLev Nov 11, 2024
db65ea8
added GitPython installation to version siwthcer workflow
ZergLev Nov 11, 2024
64c9362
debugging version switcher workflow
ZergLev Nov 11, 2024
8a3c761
fixed typo (wrong directory used when copying switcher)
ZergLev Nov 11, 2024
9dc5557
fixed typo
ZergLev Nov 11, 2024
a56e14d
debugging version switcher workflow
ZergLev Nov 11, 2024
73caab5
fixed typo (didn't call switcher generating function from the relevan…
ZergLev Nov 11, 2024
7474e05
switcher_gen workflow works now, enabling GitHub CLI to trigger it
ZergLev Nov 11, 2024
0178831
cancelling switcher-gen in progress for all branches
ZergLev Nov 11, 2024
41afdaf
cancelling switcher-gen in progress for all branches
ZergLev Nov 11, 2024
4a997e7
removed debug output
ZergLev Nov 11, 2024
9eefcd2
zerglev changed into deeppavlov for PR
ZergLev Nov 11, 2024
29dd9fc
switcher generator workflow starts with a proper trigger now, formatt…
ZergLev Nov 13, 2024
c2a730e
tutorial source files updated to install deps from poetry.lock file
ZergLev Nov 13, 2024
615932e
trying to fix InstallationCell's static method, testing
ZergLev Nov 13, 2024
fd87b31
fixed my own typo in test_tutorials
ZergLev Nov 13, 2024
d4a4ca3
testing pulling chatsky version from poetry.lock in test_tutorials()
ZergLev Nov 13, 2024
c99e982
fixed typo in test_tutorials (now saving versions_dict before(!) runn…
ZergLev Nov 13, 2024
64c5c7e
Merge branch 'master' of https://github.com/ZergLev/chatsky into feat…
ZergLev Nov 13, 2024
5c75e99
added pytest marker 'needs_dependencies' to fix test_tutorials(), als…
ZergLev Nov 18, 2024
195210e
fixed test_tutorials() with regex, testing
ZergLev Nov 18, 2024
40df25b
removed debug output in workflow, moved pytest marker into the right …
ZergLev Nov 18, 2024
95bdffe
removed redundant comments + formatted
ZergLev Nov 18, 2024
08a09f7
fixed lint, testing if it will break notebook.py
ZergLev Nov 19, 2024
a68db43
pytest marker description changed
ZergLev Nov 27, 2024
c2a8d9c
style: joined strings in a file
ZergLev Nov 27, 2024
58a0e28
refactor: using sets for easier filtering
ZergLev Nov 27, 2024
8f1801e
fixed version comparisons in version switcher generator
ZergLev Nov 27, 2024
18aa3b6
avoiding switcher_gen.py execution upon file import
ZergLev Nov 27, 2024
cd04770
refactor: added BASE_URL variable in switcher_gen.py
ZergLev Nov 27, 2024
865ee0b
refactor: stopped renaming versions into themselves (in the version s…
ZergLev Nov 27, 2024
2855d34
moved comments into a function's docstring
ZergLev Nov 27, 2024
457a6f7
Stopped adding .nojekyll every time docs are built (it's saved now)
ZergLev Nov 29, 2024
97f5f51
renamed 'github_versioned_link' into 'github_source_link'
ZergLev Nov 29, 2024
e7c7b19
Merge branch 'feat/sphinx_multiversion' of https://github.com/ZergLev…
ZergLev Nov 29, 2024
bdb860e
removed empty argument in setup()
ZergLev Nov 29, 2024
0669919
default doc_version for replacement strings switched to 'master'
ZergLev Nov 29, 2024
760d9c0
moved version switcher's vars into switcher-gen workflow
ZergLev Nov 29, 2024
e8851e8
throwing exception in case start_version doesn't fit regexp in switch…
ZergLev Nov 29, 2024
940222e
fixed comparison to start_version in switcher-gen.py
ZergLev Nov 29, 2024
05083e4
fixing test_tutorials for the case where there aren't any chatsky dep…
ZergLev Nov 29, 2024
1de6cc7
lint
ZergLev Nov 29, 2024
5f3c326
added docs for versions() func in notebook.py
ZergLev Nov 29, 2024
3c23bf3
trying to fix test_tutorials
ZergLev Nov 29, 2024
81ae07c
docstring added for generate_version_switcher()
ZergLev Nov 29, 2024
4ca5558
fixed test_tutorials locally, testing remotely
ZergLev Nov 29, 2024
51f44e2
fixed test_tutorials in GitHub CodeSpaces, testing
ZergLev Nov 29, 2024
bcf0a8e
trying to fix test_tutorials, testing
ZergLev Nov 29, 2024
20889e3
added replace_versions func in test_tutorials, also probably fixed te…
ZergLev Nov 29, 2024
a0db3f9
fixed circular import
ZergLev Nov 29, 2024
db5c67a
trying to fix test_tutorials
ZergLev Nov 29, 2024
e1cf269
trying to fix test_tutorials (attempting a configuration which alread…
ZergLev Nov 29, 2024
86ebad5
test_tutorials trying the exact configs to fix it
ZergLev Nov 29, 2024
09b1f62
debugging test_tutorials
ZergLev Nov 29, 2024
0572c39
moved replace_versions into InstallationCell, accounting for capture …
ZergLev Nov 29, 2024
a4f88d2
final fix for test_tutorials (noqa removed from tutorials for clarity)
ZergLev Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions .github/workflows/build_and_publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: fetch gh-pages branch
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
git checkout gh-pages
git checkout ${{ env.BRANCH_NAME }}

- name: set up python 3.9
uses: actions/setup-python@v5
Expand All @@ -45,9 +54,6 @@ jobs:
run: |
python -m poetry run poe docs

- name: remove jekyll theming
run: touch docs/build/.nojekyll

- name: save branch name without slashes
if: ${{ github.ref != 'refs/heads/master' }}
env:
Expand All @@ -58,17 +64,37 @@ jobs:
echo BRANCH_NAME=${BRANCH_NAME} >> $GITHUB_ENV

- name: save artifact
ZergLev marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ github.ref != 'refs/heads/master' }}
uses: actions/upload-artifact@v4
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
with:
name: ${{ format('github-pages-for-branch-{0}', env.BRANCH_NAME) }}
RLKRo marked this conversation as resolved.
Show resolved Hide resolved
path: docs/build/
retention-days: 3

- name: save branch and checkout to gh-pages
run: |
git add -f .
git stash
git checkout gh-pages

- name: delete previous docs build for this branch
uses: EndBug/[email protected]
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
with:
remove: '-r --ignore-unmatch ./${{ env.BRANCH_NAME }}'

- name: checkout to original branch and reapply changes
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
git checkout ${{ env.BRANCH_NAME }}
git stash pop

- name: deploy website
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/build/
single-commit: True
clean: False
Empty file added docs/source/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions docs/source/_static/switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"name": "0.8.0(stable)",
"version": "v0.8.0",
"url": "https://deeppavlov.github.io/dialog_flow_framework/master/index.html"
},
{
"name": "latest(dev)",
"version": "dev",
"url": "https://deeppavlov.github.io/dialog_flow_framework/dev/index.html"
}
]
124 changes: 124 additions & 0 deletions docs/source/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from __future__ import annotations
import enum
import os
import sys
import shutil
import importlib.util
from logging import getLogger
from pathlib import Path, PurePath
from subprocess import CalledProcessError
from typing import TYPE_CHECKING, Any, Iterable

from sphinx_polyversion.builder import Builder, BuildError
from sphinx_polyversion.environment import Environment
from sphinx_polyversion.json import GLOBAL_ENCODER, JSONable

if TYPE_CHECKING:
import json

import scripts.doc
from sphinx_polyversion.sphinx import CommandBuilder, Placeholder


class DffSphinxBuilder(CommandBuilder):
def __init__(
self,
source: str | PurePath,
args: Iterable[str] = [],
encoder: json.JSONEncoder | None = None,
pre_cmd: Iterable[str | Placeholder] | None = None,
post_cmd: Iterable[str | Placeholder] | None = None,
) -> None:
cmd: Iterable[str | Placeholder] = [
"sphinx-build",
"--color",
*args,
Placeholder.SOURCE_DIR,
Placeholder.OUTPUT_DIR,
]
super().__init__(
source,
cmd,
encoder=encoder,
pre_cmd=pre_cmd,
post_cmd=post_cmd,
)
self.args = args

async def build(
self, environment: Environment, output_dir: Path, data: JSONable
) -> None:
"""
Build and render a documentation.

This method runs the command the instance was created with.
The metadata will be passed to the subprocess encoded as json
using the `POLYVERSION_DATA` environment variable.

Parameters
----------
RLKRo marked this conversation as resolved.
Show resolved Hide resolved
environment : Environment
The environment to use for building.
output_dir : Path
The output directory to build to.
data : JSONable
The metadata to use for building.
"""
self.logger.info("Building...")
source_dir = str(environment.path.absolute() / self.source)

def replace(v: Any) -> str:
if v == Placeholder.OUTPUT_DIR:
return str(output_dir)
if v == Placeholder.SOURCE_DIR:
return source_dir
return str(v)

env = os.environ.copy()
env["POLYVERSION_DATA"] = self.encoder.encode(data)

cmd = tuple(map(replace, self.cmd))

# create output directory
output_dir.mkdir(exist_ok=True, parents=True)

# Importing version-dependent module setup.py
root_dir = environment.path.absolute()
os.system("ls" + str(source_dir))
ZergLev marked this conversation as resolved.
Show resolved Hide resolved
spec = importlib.util.spec_from_file_location("setup", str(source_dir) + "/setup.py")
setup_module = importlib.util.module_from_spec(spec)
sys.modules["setup"] = setup_module
spec.loader.exec_module(setup_module)

# doing DFF funcs before doc building
scripts.doc.dff_funcs(str(root_dir))
setup_module.setup(str(root_dir), str(output_dir))

# Replacing old conf.py file with the newest one
# This shouldn't be there in builders for older versions.
RLKRo marked this conversation as resolved.
Show resolved Hide resolved
newer_conf_path = (os.getcwd() + "/docs/source/conf.py")
older_conf_path = str(source_dir) + "/conf.py"
shutil.copyfile(newer_conf_path, older_conf_path)

# Removing Jekyll theming
open(str(output_dir) + '/.nojekyll', 'a')

# pre hook
if self.pre_cmd:
out, err, rc = await environment.run(*map(replace, self.pre_cmd), env=env)
if rc:
raise BuildError from CalledProcessError(rc, " ".join(cmd), out, err)

# build command
out, err, rc = await environment.run(*cmd, env=env)

self.logger.debug("Installation output:\n %s", out)
if rc:
raise BuildError from CalledProcessError(rc, " ".join(cmd), out, err)

# post hook
if self.post_cmd:
out, err, rc = await environment.run(*map(replace, self.post_cmd), env=env)
if rc:
raise BuildError from CalledProcessError(rc, " ".join(cmd), out, err)

73 changes: 23 additions & 50 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

sys.path.append(os.path.abspath("."))
from utils.notebook import py_percent_to_notebook # noqa: E402
from utils.generate_tutorials import generate_tutorial_links_for_notebook_creation # noqa: E402
from utils.link_misc_files import link_misc_files # noqa: E402
from utils.regenerate_apiref import regenerate_apiref # noqa: E402
from sphinx_polyversion import load
from sphinx_polyversion.git import GitRef

# -- Project information -----------------------------------------------------

data = load(globals()) # adds variables `current` and `revisions`
current: GitRef = data['current']

_distribution_metadata = importlib.metadata.metadata('dff')

project = _distribution_metadata["Name"]
Expand Down Expand Up @@ -57,7 +59,6 @@

add_module_names = False


# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down Expand Up @@ -111,6 +112,17 @@
"css/custom.css",
]

# Version switcher url
switcher_url = "https://zerglev.github.io/dialog_flow_framework/master/_static/switcher.json"
RLKRo marked this conversation as resolved.
Show resolved Hide resolved
# Could make a better url. Could it be stored in dev? Should it be passed to older versions somehow? This should be addressed before release.
ZergLev marked this conversation as resolved.
Show resolved Hide resolved

# Checking for dev before passing version to switcher
if current[0] == "dev":
version_data = "dev"
# Need to use metadata to show the warning banner for unstable version.
RLKRo marked this conversation as resolved.
Show resolved Hide resolved
else:
version_data = version

# Theme options
html_theme_options = {
"header_links_before_dropdown": 5,
Expand Down Expand Up @@ -139,9 +151,15 @@
},
],
"secondary_sidebar_items": ["page-toc", "source-links", "example-links"],
"switcher": {
"json_url": switcher_url,
"version_match" : version_data,
},
"navbar_persistent": ["search-button.html", "theme-switcher.html"],
"navbar_end": ["version-switcher.html", "navbar-icon-links.html"],
"show_version_warning_banner": True,
}


favicons = [
{"href": "images/logo-dff.svg"},
]
Expand All @@ -154,48 +172,3 @@
"member-order": "bysource",
"exclude-members": "_abc_impl, model_fields",
}


def setup(_):
link_misc_files(
[
"utils/db_benchmark/benchmark_schema.json",
"utils/db_benchmark/benchmark_streamlit.py",
]
)
generate_tutorial_links_for_notebook_creation(
[
("tutorials.context_storages", "Context Storages"),
(
"tutorials.messengers",
"Interfaces",
[
("telegram", "Telegram"),
("web_api_interface", "Web API"),
],
),
("tutorials.pipeline", "Pipeline"),
(
"tutorials.script",
"Script",
[
("core", "Core"),
("responses", "Responses"),
],
),
("tutorials.utils", "Utils"),
("tutorials.stats", "Stats"),
]
)
regenerate_apiref(
[
("dff.context_storages", "Context Storages"),
("dff.messengers", "Messenger Interfaces"),
("dff.pipeline", "Pipeline"),
("dff.script", "Script"),
("dff.stats", "Stats"),
("dff.utils.testing", "Testing Utils"),
("dff.utils.turn_caching", "Caching"),
("dff.utils.db_benchmark", "DB Benchmark"),
]
)
68 changes: 68 additions & 0 deletions docs/source/poly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from pathlib import Path
from datetime import datetime
from functools import partial
from sphinx_polyversion import *
from sphinx_polyversion.git import *
from sphinx_polyversion.git import closest_tag
from sphinx_polyversion.pyvenv import Poetry
from docs.source.builder import DffSphinxBuilder

#: Regex matching the branches to build docs for
# BRANCH_REGEX = r"((?!master).)*"
# Put all branches here except master, so docs can be built for any branch
# if the workflow is launched from it.
BRANCH_REGEX = r".*"


#: Regex matching the tags to build docs for
TAG_REGEX = r"(v0.8.0)"
RLKRo marked this conversation as resolved.
Show resolved Hide resolved
# That was just 0.8.0, should change that to auto tags at some point.
# Could just check always what version is being released, but I'm not sure how to do that yet.
# For now this means someone has to change this on every single release to whatever the release tag will be. Potentially, if a mistake is made, this can be changed in dev and launched from there, just don't forget to fetch 'master' branch.

#: Output dir relative to project root
OUTPUT_DIR = "docs/build"

#: Source directory
SOURCE_DIR = "docs/source"

#: Arguments to pass to `poetry install`
POETRY_ARGS = "--with tutorials,docs --all-extras --no-ansi --no-interaction".split()

#: Arguments to pass to `sphinx-build`
SPHINX_ARGS = "-b html -W --keep-going -v".split()

#: Mock data used for building local version
MOCK_DATA = {
"revisions": [
GitRef("dev", "", "", GitRefType.BRANCH, datetime.fromtimestamp(0)),
GitRef("master", "", "", GitRefType.BRANCH, datetime.fromtimestamp(1)),
],
"current": GitRef("local", "", "", GitRefType.BRANCH, datetime.fromtimestamp(2)),
}
MOCK = False
RLKRo marked this conversation as resolved.
Show resolved Hide resolved

# Load overrides read from commandline to global scope
apply_overrides(globals())

# Determine repository root directory
root = Git.root(Path(__file__).parent)
src = Path(SOURCE_DIR)

# Setup driver and run it
DefaultDriver(
root,
OUTPUT_DIR,
vcs=Git(
branch_regex=BRANCH_REGEX,
tag_regex=TAG_REGEX,
buffer_size=1 * 10**9, # 1 GB
predicate=file_predicate([src]), # exclude refs without source dir
),
builder=DffSphinxBuilder(src, args=SPHINX_ARGS),
env=Poetry.factory(args=POETRY_ARGS),
selector=partial(closest_tag, root),
template_dir=root / src / "templates",
static_dir=root / src / "static",
mock=MOCK_DATA,
).run(MOCK)
Loading
Loading