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

Switch the reference documentation to Antora #30414

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
00a08da
Remove core- prefix from .adoc files
rwinch Apr 18, 2023
4730900
Remove data-access- prefix from .adoc files
rwinch Apr 18, 2023
b1ceee4
Remove integration- prefix from .adoc files
rwinch Apr 18, 2023
2bb9c17
Remove -languages suffix from .adoc files
rwinch Apr 18, 2023
4d4e5c2
Remove duplicated testing from .adoc file path
rwinch Apr 18, 2023
6320416
Migrate Structure
rwinch Apr 19, 2023
34856b3
Insert explicit ids for headers
rwinch Apr 19, 2023
c346e73
Remove unnecessary asciidoc attributes
rwinch Apr 19, 2023
eb37a2e
Fix image::image
rwinch Apr 19, 2023
c6fae52
Copy default antora files
rwinch Apr 19, 2023
99ccdba
Split files
rwinch Apr 19, 2023
385800e
Generate a default navigation
rwinch Apr 19, 2023
3b68f5e
Remove includes
rwinch Apr 19, 2023
8496778
Fix cross references
rwinch Apr 19, 2023
8ed1245
Enable Section Summary TOC for small pages
rwinch Apr 19, 2023
987ebed
fix framework-docs.gradle
rwinch Apr 18, 2023
d3de886
Fix antora.yml gradle command
rwinch Apr 18, 2023
894c6e0
fix antora.yml attributes
rwinch Apr 18, 2023
198b054
Fix invalid attributes
rwinch Apr 18, 2023
7b1cdae
Fix index Overview link
rwinch Apr 19, 2023
616cdd3
Fix invalid nav elements
rwinch Apr 19, 2023
a26fde0
Use include-code Macro
rwinch Apr 19, 2023
e95e907
Fix Title in antora.yml
rwinch Apr 19, 2023
2ed58ec
Make local build (temporary)
rwinch Apr 19, 2023
ac270ec
Trim IDs with parent
rwinch Apr 20, 2023
e23d2fa
Structural Fixes
rwinch Apr 20, 2023
04433c5
Add ./github/workflow/deploy-docs.yml
rwinch Apr 20, 2023
a8ba7e7
Migrate to Asciidoctor Tabs
rwinch Apr 20, 2023
5abc829
Use the shared antora playbook
rwinch May 3, 2023
de738e8
Remove invalid deploy-docs.yml
rwinch May 3, 2023
5e43a7a
Fix Web Reactive link on the landing page
rwinch May 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 32 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy Docs
on:
push:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest an allow-list of exact branches to consider, rather than branches-ignore.
Similarly, I would suggest restricting the tags to something like 'v[0-9]+.[0-9]+.[0-9]+'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I'm wondering if maintaining this list, or even ignoring gh-pages, is worth it given that the logic to decide if a workflow event is triggered is:

The following steps occur to trigger a workflow run:

  1. An event occurs on your repository. The event has an associated commit SHA and Git ref.

  2. GitHub searches the .github/workflows directory in your repository for workflow files that are present in the associated commit SHA or Git ref of the event.

  3. A workflow run is triggered for any workflows that have on: values that match the triggering event. Some events also require the workflow file to be present on the default branch of the repository in order to run.

Each workflow run will use the version of the workflow that is present in the associated commit SHA or Git ref of the event. When a workflow runs, GitHub sets the GITHUB_SHA (commit SHA) and GITHUB_REF (Git ref) environment variables in the runner environment. For more information, see "Variables."

I view the branches-ignore attribute as a redundancy since unless someone merges the workflow into a branch or tag that you want to exclude, the workflow will not be considered. Excluding gh-pages is fairly simple, but maintaining a list of tags and branches (or expression/s that does the same) to include seems unnecessary overhead given that the workflow file will not be present.

Is there a specific concern you have here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've merged the changes in for now. Let's take this as a follow-up if needed, depending on the outcome of the discussion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. No specific concern, just a habit I got.

I guess for the framework team it doesn't happen that often that a branch would be created in the original repository, although we do have a couple of leftover branches.
But I guess if such a branch was created (e.g. for an experiment) it would have the file unless if it is an orphan branch (like docs-build).

There's the if: github.repository_owner check lower in the jobs which should broadly prevent any abuse from forks, so this should be fine from that perspective.

branches-ignore: [ gh-pages ]
tags: '**'
repository_dispatch:
types: request-build-reference # legacy
schedule:
- cron: '0 10 * * *' # Once per day at 10am UTC
workflow_dispatch:
permissions:
actions: write
jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'spring-projects'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: docs-build
fetch-depth: 1
- name: Dispatch (partial build)
if: github.ref_type == 'branch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
- name: Dispatch (full build)
if: github.ref_type == 'tag'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ atlassian-ide-plugin.xml

# VS Code
.vscode/

cached-antora-playbook.yml
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ configure(rootProject) {

nohttp {
source.exclude "**/test-output/**"
source.exclude "**/.gradle/**"
allowlistFile = project.file("src/nohttp/allowlist.lines")
def rootPath = file(rootDir).toPath()
def projectDirs = allprojects.collect { it.projectDir } + "${rootDir}/buildSrc"
Expand Down
32 changes: 32 additions & 0 deletions framework-docs/antora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: framework
version: true
title: Spring Framework
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
command: gradlew -q -PbuildSrc.skipTests=true "-Dorg.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError" :framework-docs:generateAntoraResources
local: true
scan:
dir: ./build/generated-antora-resources

asciidoc:
attributes:
attribute-missing: 'warn'
# FIXME: the copyright is not removed
# FIXME: The package is not renamed
chomp: 'all'
include-java: 'example$docs-src/main/java/org/springframework/docs'
spring-framework-main-code: 'https://github.com/spring-projects/spring-framework/tree/main'
docs-site: 'https://docs.spring.io'
docs-spring: "{docs-site}/spring-framework/docs/{spring-version}"
docs-spring-framework: '{docs-site}/spring-framework/docs/{spring-version}'
api-spring-framework: '{docs-spring-framework}/javadoc-api/org/springframework'
docs-graalvm: 'https://www.graalvm.org/22.3/reference-manual'
docs-spring-boot: '{docs-site}/spring-boot/docs/current/reference'
docs-spring-gemfire: '{docs-site}/spring-gemfire/docs/current/reference'
docs-spring-security: '{docs-site}/spring-security/reference'
gh-rsocket: 'https://github.com/rsocket'
gh-rsocket-extensions: '{gh-rsocket}/rsocket/blob/master/Extensions'
gh-rsocket-java: '{gh-rsocket}/rsocket-java{gh-rsocket}/rsocket-java'
136 changes: 56 additions & 80 deletions framework-docs/framework-docs.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
plugins {
id 'kotlin'
id 'io.spring.antora.generate-antora-yml' version '0.0.1'
id 'org.antora' version '1.0.0'
}

description = "Spring Framework Docs"

apply plugin: 'kotlin'
apply plugin: 'org.asciidoctor.jvm.convert'
apply plugin: 'org.asciidoctor.jvm.pdf'
apply from: "${rootDir}/gradle/publications.gradle"


configurations {
asciidoctorExtensions
antora {
version = '3.2.0-alpha.2'
playbook = 'cached-antora-playbook.yml'
playbookProvider {
repository = 'rwinch/spring-framework'
branch = 'docs-build'
path = 'lib/antora/templates/per-branch-antora-playbook.yml'
checkLocalBranch = true
}
options = ['--clean', '--stacktrace']
environment = [
'ALGOLIA_API_KEY': '82c7ead946afbac3cf98c32446154691',
'ALGOLIA_APP_ID': '244V8V9FGG',
'ALGOLIA_INDEX_NAME': 'framework-docs'
]
dependencies = [
'@antora/atlas-extension': '1.0.0-alpha.1',
'@antora/collector-extension': '1.0.0-alpha.3',
'@asciidoctor/tabs': '1.0.0-beta.3',
'@opendevise/antora-release-line-extension': '1.0.0-alpha.2',
'@springio/antora-extensions': '1.3.0',
'@springio/asciidoctor-extensions': '1.0.0-alpha.9'
]
}

dependencies {
api(project(":spring-context"))
api(project(":spring-web"))
api("jakarta.servlet:jakarta.servlet-api")

implementation(project(":spring-core-test"))
implementation("org.assertj:assertj-core")
tasks.named("generateAntoraYml") {
asciidocAttributes = project.provider( {
return ["spring-version": project.version ]
} )
}

tasks.create("generateAntoraResources") {
dependsOn 'generateAntoraYml'
}

tasks.named("check") {
dependsOn 'antora'
}

jar {
Expand All @@ -27,8 +57,19 @@ javadoc {
enabled = false
}

repositories {
maven {
url "https://repo.spring.io/release"
}
}

dependencies {
asciidoctorExtensions "io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.5"
api(project(":spring-context"))
api(project(":spring-web"))
api("jakarta.servlet:jakarta.servlet-api")

implementation(project(":spring-core-test"))
implementation("org.assertj:assertj-core")
}

/**
Expand Down Expand Up @@ -82,69 +123,10 @@ rootProject.tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(project.file("$buildDir/docs/kdoc"))
}

asciidoctorj {
version = '2.4.3'
fatalWarnings ".*"
options doctype: 'book', eruby: 'erubis'
attributes([
icons: 'font',
idprefix: '',
idseparator: '-',
revnumber: project.version,
sectanchors: '',
sectnums: '',
'spring-version': project.version
])
}

/**
* Generate the Spring Framework Reference documentation from
* "src/docs/asciidoc" in "build/docs/ref-docs/html5".
*/
asciidoctor {
baseDirFollowsSourceDir()
configurations "asciidoctorExtensions"
sources {
include '*.adoc'
}
resources {
from(sourceDir) {
include 'images/*.png'
}
}
outputDir "$buildDir/docs/ref-docs/html5"
outputOptions {
backends "spring-html"
}
forkOptions {
jvmArgs += ["--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED"]
}
logDocuments = true
}

asciidoctor.mustRunAfter "check"

/**
* Generate the Spring Framework Reference documentation from "src/docs/asciidoc"
* in "build/docs/ref-docs/pdf".
*/
asciidoctorPdf {
baseDirFollowsSourceDir()
configurations 'asciidoctorExtensions'
sources {
include 'spring-framework.adocbook'
}
outputDir "$buildDir/docs/ref-docs/pdf"
forkOptions {
jvmArgs += ["--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED"]
}
logDocuments = true
}

/**
* Zip all docs (API and reference) into a single archive
* Zip all Java docs (javadoc & kdoc) into a single archive
*/
task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor', 'asciidoctorPdf', rootProject.tasks.dokkaHtmlMultiModule]) {
task docsZip(type: Zip, dependsOn: ['api', rootProject.tasks.dokkaHtmlMultiModule]) {
group = "Distribution"
description = "Builds -${archiveClassifier} archive containing api and reference " +
"for deployment at https://docs.spring.io/spring-framework/docs/."
Expand All @@ -157,12 +139,6 @@ task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor', 'asciidoctorPdf', root
from (api) {
into "javadoc-api"
}
from ("$asciidoctor.outputDir") {
into "reference/html"
}
from ("$asciidoctorPdf.outputDir") {
into "reference/pdf"
}
from (rootProject.tasks.dokkaHtmlMultiModule.outputDirectory) {
into "kdoc-api"
}
Expand Down Expand Up @@ -251,4 +227,4 @@ publishing {
artifact distZip
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading