Skip to content

Commit

Permalink
refactor(*:skip) Move docs from doc to docs (#4660)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel J. Beutel <[email protected]>
Co-authored-by: Taner Topal <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent d67c38f commit 85b5855
Show file tree
Hide file tree
Showing 59 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/baselines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
FILTER+=$(echo "$DIR: ${BASELINES_PATH}/**\n")
done < <(find baselines -maxdepth 1 \
-name ".*" -prune -o \
-path "baselines/doc" -prune -o \
-path "baselines/docs" -prune -o \
-path "baselines/dev" -prune -o \
-path "baselines/baseline_template" -prune -o \
-path "baselines/flwr_baselines" -prune -o \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
11 changes: 8 additions & 3 deletions baselines/doc/source/conf.py → baselines/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Config for Sphinx docs."""


import datetime
import os
import sys
from sphinx.application import ConfigError


# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -120,11 +121,15 @@

nbsphinx_execute = "never"

_open_in_colab_button = """
colab_link = (
"https://colab.research.google.com/github/adap/flower/blob/main/"
"doc/source/{{ env.doc2path(env.docname, base=None) }}"
)
_open_in_colab_button = f"""
.. raw:: html
<br/>
<a href="https://colab.research.google.com/github/adap/flower/blob/main/doc/source/{{ env.doc2path(env.docname, base=None) }}">
<a href="{colab_link}">
<img alt="Open in Colab" src="https://colab.research.google.com/assets/colab-badge.svg"/>
</a>
"""
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion datasets/dev/build-flwr-datasets-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

set -e

cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../doc
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../docs

# Remove the old docs from source/ref-api
REF_API_DIR="source/ref-api"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions datasets/doc/source/conf.py → datasets/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import datetime
import os
import sys

from sphinx.application import ConfigError

# Configuration file for the Sphinx documentation builder.
Expand Down Expand Up @@ -162,7 +163,7 @@ def find_test_modules(package_path):
.. raw:: html
<br/>
<a href="https://colab.research.google.com/github/adap/flower/blob/main/datasets/doc/source/{{ env.doc2path(env.docname, base=None) }}">
<a href="https://colab.research.google.com/github/adap/flower/blob/main/datasets/docs/source/{{ env.doc2path(env.docname, base=None) }}">
<img alt="Open in Colab" src="https://colab.research.google.com/assets/colab-badge.svg"/>
</a>
"""
Expand All @@ -182,5 +183,5 @@ def find_test_modules(package_path):
myst_heading_anchors = 3

# -- Options for sphinx_copybutton -------------------------------------
copybutton_exclude = '.linenos, .gp, .go'
copybutton_exclude = ".linenos, .gp, .go"
copybutton_prompt_text = ">>> "
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions dev/build-baseline-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../

ROOT=`pwd`
INDEX=$ROOT/baselines/doc/source/index.rst
INDEX=$ROOT/baselines/docs/source/index.rst

initial_text=$(cat <<-END
.. toctree::
Expand Down Expand Up @@ -56,7 +56,7 @@ function add_table_entry ()

! grep -q ":caption: References" $INDEX && echo "$initial_text" >> $INDEX && echo "" >> $INDEX

rm -f "baselines/doc/source/*.md"
rm -f "baselines/docs/source/*.md"

cd $ROOT/baselines/

Expand All @@ -67,12 +67,12 @@ for d in $(printf '%s\n' */ | sort -V); do
# Select directories
baseline=${d%/}

if ! [[ "$baseline" =~ ^(baseline_template|dev|doc|flwr_baselines)$ ]]; then
if ! [[ "$baseline" =~ ^(baseline_template|dev|docs|flwr_baselines)$ ]]; then
# For each baseline, copy the README into the source of the Baselines docs
cp $baseline/README.md $ROOT/baselines/doc/source/$baseline.md 2>&1 >/dev/null
cp $baseline/README.md $ROOT/baselines/docs/source/$baseline.md 2>&1 >/dev/null

gh_text="[<img src=\"_static/view-gh.png\" alt=\"View on GitHub\" width=\"200\"/>](https://github.com/adap/flower/blob/main/baselines/$baseline)"
readme_file="$ROOT/baselines/doc/source/$baseline.md"
readme_file="$ROOT/baselines/docs/source/$baseline.md"

if ! grep -Fq "$gh_text" "$readme_file"; then
awk -v text="$gh_text" '
Expand All @@ -92,8 +92,8 @@ for d in $(printf '%s\n' */ | sort -V); do
do
image_dir=$(dirname $img)

mkdir -p $ROOT/baselines/doc/source/$image_dir && cp $baseline/$img $_
images_arr+=("$ROOT/baselines/doc/source/$img")
mkdir -p $ROOT/baselines/docs/source/$image_dir && cp $baseline/$img $_
images_arr+=("$ROOT/baselines/docs/source/$img")
done

if [[ $(grep -L "$baseline" $INDEX) ]]; then
Expand All @@ -109,7 +109,7 @@ for d in $(printf '%s\n' */ | sort -V); do
fi
done

cd $ROOT/baselines/doc
cd $ROOT/baselines/docs
make html

# Restore everything back to the initial state
Expand Down
14 changes: 7 additions & 7 deletions dev/build-example-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pathlib import Path

ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
INDEX = os.path.join(ROOT, "examples", "doc", "source", "index.rst")
INDEX = os.path.join(ROOT, "examples", "docs", "source", "index.rst")

initial_text = """
Flower Examples Documentation
Expand Down Expand Up @@ -180,14 +180,14 @@ def _copy_markdown_files(example):
if file.endswith(".md"):
src = os.path.join(example, file)
dest = os.path.join(
ROOT, "examples", "doc", "source", os.path.basename(example) + ".md"
ROOT, "examples", "docs", "source", os.path.basename(example) + ".md"
)
shutil.copyfile(src, dest)


def _add_gh_button(example):
gh_text = f'[<img src="_static/view-gh.png" alt="View on GitHub" width="200"/>](https://github.com/adap/flower/blob/main/examples/{example})'
readme_file = os.path.join(ROOT, "examples", "doc", "source", example + ".md")
readme_file = os.path.join(ROOT, "examples", "docs", "source", example + ".md")
with open(readme_file, "r+") as f:
content = f.read()
if gh_text not in content:
Expand All @@ -201,7 +201,7 @@ def _add_gh_button(example):

def _copy_images(example):
static_dir = os.path.join(example, "_static")
dest_dir = os.path.join(ROOT, "examples", "doc", "source", "_static")
dest_dir = os.path.join(ROOT, "examples", "docs", "source", "_static")
if os.path.isdir(static_dir):
for file in os.listdir(static_dir):
if file.endswith((".jpg", ".png", ".jpeg")):
Expand All @@ -214,7 +214,7 @@ def _add_all_entries():
examples_dir = os.path.join(ROOT, "examples")
for example in sorted(os.listdir(examples_dir)):
example_path = os.path.join(examples_dir, example)
if os.path.isdir(example_path) and example != "doc":
if os.path.isdir(example_path) and example != "docs":
_copy_markdown_files(example_path)
_add_gh_button(example)
_copy_images(example)
Expand All @@ -230,7 +230,7 @@ def _main():
examples_dir = os.path.join(ROOT, "examples")
for example in sorted(os.listdir(examples_dir)):
example_path = os.path.join(examples_dir, example)
if os.path.isdir(example_path) and example != "doc":
if os.path.isdir(example_path) and example != "docs":
_copy_markdown_files(example_path)
_add_gh_button(example)
_copy_images(example_path)
Expand Down Expand Up @@ -280,4 +280,4 @@ def _main():

if __name__ == "__main__":
_main()
subprocess.call(f"cd {ROOT}/examples/doc && make html", shell=True)
subprocess.call(f"cd {ROOT}/examples/docs && make html", shell=True)
8 changes: 4 additions & 4 deletions dev/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


REPLACE_CURR_VERSION = {
"doc/source/conf.py": [
"framework/docs/source/conf.py": [
".. |stable_flwr_version| replace:: {version}",
],
"src/py/flwr/cli/new/templates/app/pyproject.*.toml.tpl": [
Expand All @@ -17,11 +17,11 @@

REPLACE_NEXT_VERSION = {
"pyproject.toml": ['version = "{version}"'],
"doc/source/conf.py": [
"framework/docs/source/conf.py": [
'release = "{version}"',
],
"examples/doc/source/conf.py": ['release = "{version}"'],
"baselines/doc/source/conf.py": ['release = "{version}"'],
"examples/docs/source/conf.py": ['release = "{version}"'],
"baselines/docs/source/conf.py": ['release = "{version}"'],
"src/docker/complete/compose.yml": ["FLWR_VERSION:-{version}"],
"src/docker/distributed/client/compose.yml": ["FLWR_VERSION:-{version}"],
"src/docker/distributed/server/compose.yml": ["FLWR_VERSION:-{version}"],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.

0 comments on commit 85b5855

Please sign in to comment.