Skip to content

Add tests checking whether the links haven't changed #14815

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

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions .github/workflows/scaladoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ jobs:
- name: Generate testcases documentation
run: ./project/scripts/sbt scaladoc/generateTestcasesDocumentation

- name: Generate reference documentation
run: ./project/scripts/sbt scaladoc/generateReferenceDocumentation
- name: Generate reference documentation and check links stability
run: |
./project/scripts/sbt scaladoc/generateReferenceDocumentation
./project/scripts/docsLinksStability ./scaladoc/output/reference ./project/scripts/expected-links/reference-expected-links.txt

- name: Generate Scala 3 documentation
run: ./project/scripts/sbt scaladoc/generateScalaDocumentation
- name: Generate Scala 3 documentation and check links stability
run: |
./project/scripts/sbt scaladoc/generateScalaDocumentation
./project/scripts/docsLinksStability ./scaladoc/output/scala3 ./project/scripts/expected-links/scala3-expected-links.txt

- name: Generate documentation for example project using dotty-sbt
run: ./project/scripts/sbt "sbt-test/scripted sbt-dotty/scaladoc"
Expand Down
23 changes: 23 additions & 0 deletions project/scripts/docsLinksStability
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -u

echo "Testing links stability in documentation"

DOCS_DIR=$1 # The location of documentation is passed as a first parameter

EXPECTED_LINKS_FILE=$2 # The location of expected-links.txt is passed as a second parameter

pushd $DOCS_DIR > /dev/null # Go to docs dir but remember previous location
# We need to go to docs dir to make find return correct relative paths
find . -type f -name "*.html" | sort | (popd > /dev/null; diff $EXPECTED_LINKS_FILE -;)
# We list every html file in documentation, then sort it and finally compare to the expected links list.
# Before running diff we need to popd to return to the previous location because we don't have relative path to the expected links file.

if [ ! $? -eq 0 ]
then
echo "Links changed. If it's intentional, regenerate expected links list by running ./project/scripts/regenerateExpectedLinks $1 $2"
exit -1
else
echo "Links OK!"
exit 0
fi
120 changes: 120 additions & 0 deletions project/scripts/expected-links/reference-expected-links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
./changed-features/compiler-plugins.html
./changed-features/eta-expansion-spec.html
./changed-features/eta-expansion.html
./changed-features/implicit-conversions-spec.html
./changed-features/implicit-conversions.html
./changed-features/implicit-resolution.html
./changed-features/imports.html
./changed-features/index.html
./changed-features/lazy-vals-init.html
./changed-features/main-functions.html
./changed-features/match-syntax.html
./changed-features/numeric-literals.html
./changed-features/operators.html
./changed-features/overload-resolution.html
./changed-features/pattern-bindings.html
./changed-features/pattern-matching.html
./changed-features/structural-types-spec.html
./changed-features/structural-types.html
./changed-features/type-checking.html
./changed-features/type-inference.html
./changed-features/vararg-splices.html
./changed-features/wildcards.html
./contextual/by-name-context-parameters.html
./contextual/context-bounds.html
./contextual/context-functions-spec.html
./contextual/context-functions.html
./contextual/conversions.html
./contextual/derivation-macro.html
./contextual/derivation.html
./contextual/extension-methods.html
./contextual/given-imports.html
./contextual/givens.html
./contextual/index.html
./contextual/multiversal-equality.html
./contextual/relationship-implicits.html
./contextual/right-associative-extension-methods.html
./contextual/type-classes.html
./contextual/using-clauses.html
./docs/reference/other-new-features/named-typeargs.html
./docsScalaLangResources/scaladoc-assets.html
./dropped-features/auto-apply.html
./dropped-features/class-shadowing-spec.html
./dropped-features/class-shadowing.html
./dropped-features/delayed-init.html
./dropped-features/do-while.html
./dropped-features/early-initializers.html
./dropped-features/existential-types.html
./dropped-features/index.html
./dropped-features/limit22.html
./dropped-features/macros.html
./dropped-features/nonlocal-returns.html
./dropped-features/package-objects.html
./dropped-features/procedure-syntax.html
./dropped-features/symlits.html
./dropped-features/this-qualifier.html
./dropped-features/type-projection.html
./dropped-features/weak-conformance-spec.html
./dropped-features/weak-conformance.html
./dropped-features/wildcard-init.html
./dropped-features/xml.html
./enums/adts.html
./enums/desugarEnums.html
./enums/enums.html
./enums/index.html
./experimental/canthrow.html
./experimental/cc.html
./experimental/erased-defs-spec.html
./experimental/erased-defs.html
./experimental/explicit-nulls.html
./experimental/index.html
./experimental/named-typeargs-spec.html
./experimental/named-typeargs.html
./experimental/numeric-literals.html
./experimental/overview.html
./features-classification.html
./index.html
./language-versions/binary-compatibility.html
./language-versions/index.html
./language-versions/source-compatibility.html
./metaprogramming/compiletime-ops.html
./metaprogramming/index.html
./metaprogramming/inline.html
./metaprogramming/macros-spec.html
./metaprogramming/macros.html
./metaprogramming/reflection.html
./metaprogramming/staging.html
./metaprogramming/tasty-inspect.html
./new-types/dependent-function-types-spec.html
./new-types/dependent-function-types.html
./new-types/index.html
./new-types/intersection-types-spec.html
./new-types/intersection-types.html
./new-types/match-types.html
./new-types/polymorphic-function-types.html
./new-types/type-lambdas-spec.html
./new-types/type-lambdas.html
./new-types/union-types-spec.html
./new-types/union-types.html
./other-new-features/control-syntax.html
./other-new-features/creator-applications.html
./other-new-features/experimental-defs.html
./other-new-features/export.html
./other-new-features/indentation.html
./other-new-features/index.html
./other-new-features/kind-polymorphism.html
./other-new-features/matchable.html
./other-new-features/opaques-details.html
./other-new-features/opaques.html
./other-new-features/open-classes.html
./other-new-features/parameter-untupling-spec.html
./other-new-features/parameter-untupling.html
./other-new-features/safe-initialization.html
./other-new-features/targetName.html
./other-new-features/threadUnsafe-annotation.html
./other-new-features/trait-parameters.html
./other-new-features/transparent-traits.html
./other-new-features/type-test.html
./overview.html
./soft-modifier.html
./syntax.html
Loading