From 1c3aea7fed6799da44a0e664df17b1723df5c6c4 Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 14 Oct 2023 11:21:59 +0100 Subject: [PATCH] Add table of baselines to docs (#2400) Co-authored-by: Charles Beauville Co-authored-by: Taner Topal --- baselines/doc/source/index.rst | 2 ++ dev/build-baseline-docs.sh | 46 ++++++++++++++++++++++++++++++++++ doc/source/ref-changelog.md | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/baselines/doc/source/index.rst b/baselines/doc/source/index.rst index b35a20f29af1..0aacbc28d117 100644 --- a/baselines/doc/source/index.rst +++ b/baselines/doc/source/index.rst @@ -21,6 +21,8 @@ Flower Baselines Flower Baselines are a collection of organised scripts used to reproduce results from well-known publications or benchmarks. You can check which baselines already exist and/or contribute your own baseline. +.. BASELINES_TABLE_ANCHOR + Tutorials ~~~~~~~~~ diff --git a/dev/build-baseline-docs.sh b/dev/build-baseline-docs.sh index 36a816426bb8..b7403f516969 100755 --- a/dev/build-baseline-docs.sh +++ b/dev/build-baseline-docs.sh @@ -12,6 +12,48 @@ initial_text=$(cat <<-END END ) +table_body="\\ +.. list-table:: \\ + :widths: 15 15 50\\ + :header-rows: 1\\ + \\ + * - Method\\ + - Dataset\\ + - Tags\\ + .. BASELINES_TABLE_ENTRY\\ + " + + +function add_table_entry () +{ + # extract lines from markdown file between --- and ---, preserving newlines and store in variable called metadata + metadata=$(awk '/^---$/{flag=1; next} flag; /^---$/{exit}' $1/README.md) + + # get text after "title:" in metadata using sed + title=$(echo "$metadata" | sed -n 's/title: //p') + + # get text after "url:" in metadata using sed + url=$(echo "$metadata" | sed -n 's/url: //p') + + # get text after "labels:" in metadata using sed + labels=$(echo "$metadata" | sed -n 's/labels: //p' | sed 's/\[//g; s/\]//g') + + # get text after "dataset:" in metadata using sed + dataset=$(echo "$metadata" | sed -n 's/dataset: //p' | sed 's/\[//g; s/\]//g') + + table_entry="\\ + * - \`$1 <$1.html>\`_\\ + - $dataset\\ + - $labels\\ + \\ +.. BASELINES_TABLE_ENTRY\ + " +} + + +# Create Sphinx table block and header +! sed -i '' -e "s/.. BASELINES_TABLE_ANCHOR/$table_body/" $INDEX + ! grep ":caption: References" $INDEX && echo "$initial_text" >> $INDEX && echo "" >> $INDEX rm -f "baselines/doc/source/*.md" @@ -46,6 +88,10 @@ for d in $(printf '%s\n' */ | sort -V); do # For each baseline, insert the name of the baseline into the index file echo " $baseline" >> $INDEX + # Add entry to the table + add_table_entry $baseline + ! sed -i '' -e "s/.. BASELINES_TABLE_ENTRY/$table_entry/" $INDEX + fi fi done diff --git a/doc/source/ref-changelog.md b/doc/source/ref-changelog.md index d06f889fe4fb..b9abad85d050 100644 --- a/doc/source/ref-changelog.md +++ b/doc/source/ref-changelog.md @@ -20,7 +20,7 @@ - FedProx ([#2210](https://github.com/adap/flower/pull/2210), [#2286](https://github.com/adap/flower/pull/2286)) - - Baselines Docs ([#2290](https://github.com/adap/flower/pull/2290)) + - Baselines Docs ([#2290](https://github.com/adap/flower/pull/2290), [#2400](https://github.com/adap/flower/pull/2400)) - **Update Flower Examples** ([#2384](https://github.com/adap/flower/pull/2384)), ([#2425](https://github.com/adap/flower/pull/2425))