From e58dbb603ea4d4d448279e4424be297b345f0e05 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Wed, 10 Feb 2021 11:01:31 +1300 Subject: [PATCH 1/9] Set version to 0.26.2 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index dee18a3060..80ee4d828f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Documenter" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "0.26.1" +version = "0.26.2" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 0ca6db61560f73f5548f668c65525a2d4a041f23 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Wed, 3 Feb 2021 12:04:12 +1300 Subject: [PATCH 2/9] Switch CI over to GitHub Actions (#1496) (cherry picked from commit 8f8c493c3673cdaa29a757f6aea741e9c9576a3a) --- .github/workflows/CI.yml | 133 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 59 ----------------- 2 files changed, 133 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000000..87d3189473 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,133 @@ +name: CI +on: + push: + branches: + - master + - release-* + pull_request: +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.0' + - '1' + - 'nightly' + os: + - ubuntu-latest + - macos-latest + # We still run Windows tests on AppVeyor because the tests are not passing on + # the Windows image of GitHub Actions: + # https://github.com/JuliaDocs/Documenter.jl/pull/1496 + #- windows-latest + arch: + - x64 + include: + - os: ubuntu-latest + version: '1' + arch: x86 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + show-versioninfo: true + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info + + latex: + name: "PDF/LaTeX backend" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - run: | + julia --project=test/examples -e ' + using Pkg + Pkg.instantiate() + Pkg.develop(PackageSpec(path=pwd())) + Pkg.add(["IOCapture", "DocumenterMarkdown"])' + - run: julia --project=test/examples test/examples/tests_latex.jl + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info + + themes: + name: "CSS for HTML themes" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - run: | + julia --project=test/themes/ -e ' + using Pkg + Pkg.instantiate() + Pkg.develop(PackageSpec(path=pwd()))' + - run: julia --project=test/themes test/themes/themes.jl + + docs: + name: 'Documentation: ${{ matrix.makejl }}' + runs-on: ubuntu-latest + strategy: + matrix: + include: + - jlenv: 'docs/' + makejl: 'docs/make.jl' + - jlenv: 'docs/pdf/' + makejl: 'docs/pdf/make.jl' + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + - run: | + julia --project=${{ matrix.jlenv }} -e ' + using Pkg + Pkg.develop(PackageSpec(path=pwd())) + Pkg.instantiate()' + - run: julia --project=${{ matrix.jlenv }} --color=yes ${{ matrix.makejl }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2af6557c14..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ -language: julia - -os: - - linux - - osx - -julia: - - 1 - - 1.4 - - 1.0 - - nightly - -branches: - only: - - master - - /^release-.*$/ - - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ - -after_success: - - if [ -f test/quietly.log ]; then cat test/quietly.log; fi - - if [[ $TRAVIS_JULIA_VERSION = 1 ]] && [[ $TRAVIS_OS_NAME = linux ]]; then - julia --project=coverage/ -e 'using Pkg; Pkg.instantiate(); - using Coverage; Codecov.submit(Codecov.process_folder())'; - fi - -jobs: - allow_failures: - - julia: nightly - include: - - stage: "Additional tests" - script: - - julia --project=test/themes -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))' - - julia --project=test/themes test/themes/themes.jl - name: "Themes" - - script: - - | - julia --project=test/examples -e ' - using Pkg - Pkg.instantiate() - Pkg.develop(PackageSpec(path=pwd())) - Pkg.add(["IOCapture", "DocumenterMarkdown"]) - ' - - julia --project=test/examples test/examples/tests_latex.jl - name: "PDF/LaTeX backend" - - stage: "Documentation" - script: - - julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - julia --project=docs/ docs/make.jl - name: "HTML" - after_success: skip - - script: - - julia --project=docs/pdf/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - julia --project=docs/pdf/ docs/pdf/make.jl - name: "PDF" - after_success: skip - services: docker - -notifications: - email: false From d8293ca9556aad5685f521368d84578f2a02d2ee Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Wed, 3 Feb 2021 07:03:01 +0100 Subject: [PATCH 3/9] Check for empty CI environment variables (#1511) * Mention that push_review doesn't work from forks * Check for empty DOCUMENTER_KEY/GITHUB_TOKEN/GITHUB_ACTOR * Clarify that deploy token and key are not both needed (cherry picked from commit 4b655e7f24d7976639219ae0076ad98e5c45bf27) --- CHANGELOG.md | 5 +++++ docs/src/man/hosting.md | 4 ++-- src/Documenter.jl | 4 +++- src/deployconfig.jl | 30 ++++++++++++++++-------------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b422e9871..d270187201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Documenter.jl changelog +## Version `v0.26.2` + +* ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511]) + ## Version `v0.26.1` * ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497]) @@ -722,6 +726,7 @@ [github-1491]: https://github.com/JuliaDocs/Documenter.jl/pull/1491 [github-1493]: https://github.com/JuliaDocs/Documenter.jl/pull/1493 [github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497 +[github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/docs/src/man/hosting.md b/docs/src/man/hosting.md index a59cbe4cc8..ad8f408f8f 100644 --- a/docs/src/man/hosting.md +++ b/docs/src/man/hosting.md @@ -199,8 +199,8 @@ jobs: run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - name: Build and deploy env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key run: julia --project=docs/ docs/make.jl ``` diff --git a/src/Documenter.jl b/src/Documenter.jl index 0655ccdda0..1f4ee0a8b2 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -405,7 +405,9 @@ the generated html. The following entries are valid in the `versions` vector: **`push_preview`** a boolean that specifies if preview documentation should be deployed from pull requests or not. If your published documentation is hosted at `"https://USER.github.io/PACKAGE.jl/stable`, by default the preview will be -hosted at `"https://USER.github.io/PACKAGE.jl/previews/PR##"`. +hosted at `"https://USER.github.io/PACKAGE.jl/previews/PR##"`. This feature +works for pull requests with head branch in the same repository, i.e. not from +forks. **`branch_previews`** is the branch to which pull request previews are deployed. It defaults to the value of `branch`. diff --git a/src/deployconfig.jl b/src/deployconfig.jl index 48ffc40652..98780bfc8d 100644 --- a/src/deployconfig.jl +++ b/src/deployconfig.jl @@ -103,6 +103,8 @@ post_status(; kwargs...) = post_status(auto_detect_deploy_system(); kwargs...) marker(x) = x ? "✔" : "✘" +env_nonempty(key) = !isempty(get(ENV, key, "")) + ############# # Travis CI # ############# @@ -227,9 +229,9 @@ function deploy_folder(cfg::Travis; subfolder = "previews/PR$(something(pr_number, 0))" end ## DOCUMENTER_KEY should exist (just check here and extract the value later) - key_ok = haskey(ENV, "DOCUMENTER_KEY") + key_ok = env_nonempty("DOCUMENTER_KEY") all_ok &= key_ok - println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists") + println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty") ## Cron jobs should not deploy type_ok = cfg.travis_event_type != "cron" all_ok &= type_ok @@ -371,20 +373,20 @@ function deploy_folder(cfg::GitHubActions; subfolder = "previews/PR$(something(pr_number, 0))" end ## GITHUB_ACTOR should exist (just check here and extract the value later) - actor_ok = haskey(ENV, "GITHUB_ACTOR") + actor_ok = env_nonempty("GITHUB_ACTOR") all_ok &= actor_ok - println(io, "- $(marker(actor_ok)) ENV[\"GITHUB_ACTOR\"] exists") + println(io, "- $(marker(actor_ok)) ENV[\"GITHUB_ACTOR\"] exists and is non-empty") ## GITHUB_TOKEN or DOCUMENTER_KEY should exist (just check here and extract the value later) - token_ok = haskey(ENV, "GITHUB_TOKEN") - key_ok = haskey(ENV, "DOCUMENTER_KEY") + token_ok = env_nonempty("GITHUB_TOKEN") + key_ok = env_nonempty("DOCUMENTER_KEY") auth_ok = token_ok | key_ok all_ok &= auth_ok if key_ok - println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists") + println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty") elseif token_ok - println(io, "- $(marker(token_ok)) ENV[\"GITHUB_TOKEN\"] exists") + println(io, "- $(marker(token_ok)) ENV[\"GITHUB_TOKEN\"] exists and is non-empty") else - println(io, "- $(marker(auth_ok)) ENV[\"DOCUMENTER_KEY\"] or ENV[\"GITHUB_TOKEN\"] exists") + println(io, "- $(marker(auth_ok)) ENV[\"DOCUMENTER_KEY\"] or ENV[\"GITHUB_TOKEN\"] exists and is non-empty") end print(io, "Deploying: $(marker(all_ok))") @info String(take!(io)) @@ -413,7 +415,7 @@ function deploy_folder(cfg::GitHubActions; end function authentication_method(::GitHubActions) - if haskey(ENV, "DOCUMENTER_KEY") + if env_nonempty("DOCUMENTER_KEY") return SSH else @warn "Currently the GitHub Pages build is not triggered when " * @@ -639,8 +641,8 @@ function deploy_folder( deploy_repo = repo end - key_ok = haskey(ENV, "DOCUMENTER_KEY") - println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists") + key_ok = env_nonempty("DOCUMENTER_KEY") + println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty") all_ok &= key_ok print(io, "Deploying to folder $(repr(subfolder)): $(marker(all_ok))") @@ -782,8 +784,8 @@ function deploy_folder( deploy_repo = repo end - key_ok = haskey(ENV, "DOCUMENTER_KEY") - println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists") + key_ok = env_nonempty("DOCUMENTER_KEY") + println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty") all_ok &= key_ok print(io, "Deploying to folder $(repr(subfolder)): $(marker(all_ok))") From d352a01adbee816586ed374de9c44bb69edb9848 Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Wed, 3 Feb 2021 07:03:57 +0100 Subject: [PATCH 4/9] Fix crash in case of empty `# output` (#1510) (cherry picked from commit dffba5fcdb314b227f65c0164a2f78c68d1d3ece) --- CHANGELOG.md | 3 +++ src/DocTests.jl | 2 +- test/doctests/src/working.md | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d270187201..a46a4f0e63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Version `v0.26.2` +* ![Bugfix][badge-bugfix] Script-type doctests that have an empty output section no longer crash Documenter. ([#1510][github-1510]) + * ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511]) ## Version `v0.26.1` @@ -726,6 +728,7 @@ [github-1491]: https://github.com/JuliaDocs/Documenter.jl/pull/1491 [github-1493]: https://github.com/JuliaDocs/Documenter.jl/pull/1493 [github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497 +[github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/src/DocTests.jl b/src/DocTests.jl index f3b0cea08a..d9d6e82751 100644 --- a/src/DocTests.jl +++ b/src/DocTests.jl @@ -239,7 +239,7 @@ function eval_script(block, sandbox, meta::Dict, doc::Documents.Document, page) # # # to mark `input`/`output` separation. - input, output = split(block.code, "# output\n", limit = 2) + input, output = split(block.code, r"^# output$"m, limit = 2) input = rstrip(input, '\n') output = lstrip(output, '\n') result = Result(block, input, output, meta[:CurrentFile]) diff --git a/test/doctests/src/working.md b/test/doctests/src/working.md index 677180caa4..0f743069da 100644 --- a/test/doctests/src/working.md +++ b/test/doctests/src/working.md @@ -52,4 +52,11 @@ Comments at the start: # .. should be ignored. julia> 2 + 2 4 -``` \ No newline at end of file +``` + +Empty output: + +```jldoctest +nothing +# output +``` From 7bc9ba832ac3d5a36c6de1220bf463f55fdb150e Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Fri, 5 Feb 2021 11:51:06 +1300 Subject: [PATCH 5/9] Fix cross-platform newline handling in doctests (#1520) Co-authored-by: Oscar Dowson (cherry picked from commit 91e3a0407b96ff9b6c9e4b19b35b6095d26fbcd7) --- .appveyor.yml | 37 ------------------------------------- .github/workflows/CI.yml | 5 +---- CHANGELOG.md | 5 +++++ test/doctests/doctests.jl | 6 ++++++ test/doctests/fix/tests.jl | 15 +++++++++++---- 5 files changed, 23 insertions(+), 45 deletions(-) delete mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 59b895272d..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,37 +0,0 @@ -environment: - matrix: - - julia_version: 1.0 - - julia_version: 1.5 - - julia_version: nightly - -platform: - - x86 # 32-bit - - x64 # 64-bit - -# Uncomment the following lines to allow failures on nightly julia -# (tests will run but not make your overall status red) -matrix: - allow_failures: - - julia_version: nightly - -branches: - only: - - master - - /release-.*/ - -notifications: - - provider: Email - on_build_success: false - on_build_failure: false - on_build_status_changed: false - -install: - - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) - -build_script: - - echo "%JL_BUILD_SCRIPT%" - - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" - -test_script: - - echo "%JL_TEST_SCRIPT%" - - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 87d3189473..f211a0d274 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,10 +19,7 @@ jobs: os: - ubuntu-latest - macos-latest - # We still run Windows tests on AppVeyor because the tests are not passing on - # the Windows image of GitHub Actions: - # https://github.com/JuliaDocs/Documenter.jl/pull/1496 - #- windows-latest + - windows-latest arch: - x64 include: diff --git a/CHANGELOG.md b/CHANGELOG.md index a46a4f0e63..ac5a596519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511]) +* ![Bugfix][badge-bugfix] Doctests now correctly handle the case when the repository has been checked out with `CRLF` line endings (which can happen on Windows with `core.autocrlf=true`). ([#1516][github-1516], [#1519][github-1519], [#1520][github-1520]) + ## Version `v0.26.1` * ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497]) @@ -730,6 +732,9 @@ [github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497 [github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 +[github-1516]: https://github.com/JuliaDocs/Documenter.jl/issues/1516 +[github-1519]: https://github.com/JuliaDocs/Documenter.jl/pull/1519 +[github-1520]: https://github.com/JuliaDocs/Documenter.jl/pull/1520 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/test/doctests/doctests.jl b/test/doctests/doctests.jl index 14ec3903a4..2558a0307b 100644 --- a/test/doctests/doctests.jl +++ b/test/doctests/doctests.jl @@ -72,6 +72,12 @@ function onormalize(s) # platform / environment / time dependent parts, so that it would actually be possible # to compare Documenter output to previously generated reference outputs. + # We need to make sure that, if we're running the tests on Windows, that we'll have consistent + # line breaks. So we'll normalize CRLF to LF. + if Sys.iswindows() + s = replace(s, "\r\n" => "\n") + end + # Remove filesystem paths in doctests failures s = replace(s, r"(doctest failure in )(.*)$"m => s"\1{PATH}") s = replace(s, r"(@ Documenter.DocTests )(.*)$"m => s"\1{PATH}") diff --git a/test/doctests/fix/tests.jl b/test/doctests/fix/tests.jl index db2bb62bb0..00abf9d620 100644 --- a/test/doctests/fix/tests.jl +++ b/test/doctests/fix/tests.jl @@ -20,6 +20,11 @@ end # The version check is necessary due to a behaviour change in https://github.com/JuliaLang/julia/pull/32851 mktempdir_nocleanup(dir) = VERSION >= v"1.3.0-alpha.112" ? mktempdir(dir, cleanup = false) : mktempdir(dir) +function normalize_line_endings(filename) + s = read(filename, String) + return replace(s, "\r\n" => "\n") +end + function test_doctest_fix(dir) srcdir = mktempdir_nocleanup(dir) builddir = mktempdir_nocleanup(dir) @@ -27,8 +32,10 @@ function test_doctest_fix(dir) # Pkg.add changes permission of files to read-only, # so instead of copying them we read + write. - write(joinpath(srcdir, "index.md"), read(joinpath(@__DIR__, "broken.md"))) - write(joinpath(srcdir, "src.jl"), read(joinpath(@__DIR__, "broken.jl"))) + src_jl = joinpath(srcdir, "src.jl") + index_md = joinpath(srcdir, "index.md") + write(index_md, normalize_line_endings(joinpath(@__DIR__, "broken.md"))) + write(src_jl, normalize_line_endings(joinpath(@__DIR__, "broken.jl"))) # fix up include(joinpath(srcdir, "src.jl")); @eval import .Foo @@ -41,8 +48,8 @@ function test_doctest_fix(dir) @quietly makedocs(sitename="-", modules = [Foo], source = srcdir, build = builddir, strict = true) # also test that we obtain the expected output - @test read(joinpath(srcdir, "index.md"), String) == read(joinpath(@__DIR__, "fixed.md"), String) - @test read(joinpath(srcdir, "src.jl"), String) == read(joinpath(@__DIR__, "fixed.jl"), String) + @test normalize_line_endings(index_md) == normalize_line_endings(joinpath(@__DIR__, "fixed.md")) + @test normalize_line_endings(src_jl) == normalize_line_endings(joinpath(@__DIR__, "fixed.jl")) end @testset "doctest fixing" begin From 313cad4b68b7888e6acb15af5758fe4c02d38c79 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 10 Feb 2021 10:52:52 +1300 Subject: [PATCH 6/9] Fix multiline display equations in HTML (#1518) (cherry picked from commit 93e253a6d8d436abc996c063d540b6ffc0a75293) --- CHANGELOG.md | 3 +++ src/Writers/HTMLWriter.jl | 6 +++--- test/examples/src/man/tutorial.md | 36 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac5a596519..8ed9d09142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * ![Bugfix][badge-bugfix] Doctests now correctly handle the case when the repository has been checked out with `CRLF` line endings (which can happen on Windows with `core.autocrlf=true`). ([#1516][github-1516], [#1519][github-1519], [#1520][github-1520]) +* ![Bugfix][badge-bugfix] Multiline equations are now correctly handled in at-block outputs. ([#1518][github-1518]) + ## Version `v0.26.1` * ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497]) @@ -733,6 +735,7 @@ [github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 [github-1516]: https://github.com/JuliaDocs/Documenter.jl/issues/1516 +[github-1518]: https://github.com/JuliaDocs/Documenter.jl/pull/1518 [github-1519]: https://github.com/JuliaDocs/Documenter.jl/pull/1519 [github-1520]: https://github.com/JuliaDocs/Documenter.jl/pull/1520 diff --git a/src/Writers/HTMLWriter.jl b/src/Writers/HTMLWriter.jl index 9c21ba6169..1edaf90b61 100644 --- a/src/Writers/HTMLWriter.jl +++ b/src/Writers/HTMLWriter.jl @@ -1762,9 +1762,9 @@ function mdconvert(d::Dict{MIME,Any}, parent; kwargs...) # unwrap it first, since when we output Markdown.LaTeX objects we put the correct # delimiters around it anyway. latex = d[MIME"text/latex"()] - equation = false - m_bracket = match(r"\s*\\\[(.*)\\\]\s*", latex) - m_dollars = match(r"\s*\$\$(.*)\$\$\s*", latex) + # Make sure to match multiline strings! + m_bracket = match(r"\s*\\\[(.*)\\\]\s*"s, latex) + m_dollars = match(r"\s*\$\$(.*)\$\$\s*"s, latex) if m_bracket === nothing && m_dollars === nothing out = Utilities.mdparse(latex; mode = :single) else diff --git a/test/examples/src/man/tutorial.md b/test/examples/src/man/tutorial.md index c117ae86be..01c0bceaaf 100644 --- a/test/examples/src/man/tutorial.md +++ b/test/examples/src/man/tutorial.md @@ -433,3 +433,39 @@ or wrapped in `$$ ... $$`: ```@example showablelatex LaTeXEquation(raw"$$\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$$") ``` + +--- + +Extra tests for handling multi-line equations ([#1518](https://github.com/JuliaDocs/Documenter.jl/pull/1518)): + + +```@example showablelatex +LaTeXEquation(raw""" +\[ + \left[ + \begin{array}{rr} + x & 2x + \end{array} + \right] +\] +""") +``` + +```@example showablelatex +LaTeXEquation(raw"""$$ +\begin{bmatrix} + 1 & 2 \\ + 3 & 4 +\end{bmatrix} +$$""") +``` + +Without `raw""` strings we have to double-escape our `\` and `$`: + +```@example showablelatex +LaTeXEquation("\\[\\left[\\begin{array}{rr} x & 2x \\\\ \n y & y \\end{array}\\right]\\]") +``` + +```@example showablelatex +LaTeXEquation("\$\$\\begin{bmatrix} 1 & 2 \\\\ \n 3 & 4 \\end{bmatrix}\$\$") +``` From ee2030b947a3a98dbba47203d336fc686e3b9c18 Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Fri, 12 Feb 2021 00:13:16 +0100 Subject: [PATCH 7/9] Remove GitHub token build trigger warning (#1517) (cherry picked from commit 8d75805af40466cd8cfa75bce52629fb7f5aa8da) --- docs/src/man/hosting.md | 6 ------ src/deployconfig.jl | 12 +----------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/docs/src/man/hosting.md b/docs/src/man/hosting.md index ad8f408f8f..47c36447bf 100644 --- a/docs/src/man/hosting.md +++ b/docs/src/man/hosting.md @@ -259,12 +259,6 @@ to the configuration file, as showed in the [previous section](@ref GitHub-Actio of the deployment is the same as the current repository. In order to push elsewhere you should instead use a SSH deploy key. -!!! warning "GitHub Pages and GitHub Token" - Currently the GitHub Page build is not triggered when the GitHub provided - `GITHUB_TOKEN` is used for authentication. See - [issue #1177](https://github.com/JuliaDocs/Documenter.jl/issues/1177) - for more information. - ### Authentication: SSH Deploy Keys It is also possible to authenticate using a SSH deploy key, just as described in diff --git a/src/deployconfig.jl b/src/deployconfig.jl index 98780bfc8d..3692276934 100644 --- a/src/deployconfig.jl +++ b/src/deployconfig.jl @@ -414,17 +414,7 @@ function deploy_folder(cfg::GitHubActions; end end -function authentication_method(::GitHubActions) - if env_nonempty("DOCUMENTER_KEY") - return SSH - else - @warn "Currently the GitHub Pages build is not triggered when " * - "using `GITHUB_TOKEN` for authentication. See issue #1177 " * - "(https://github.com/JuliaDocs/Documenter.jl/issues/1177) " * - "for more information." - return HTTPS - end -end +authentication_method(::GitHubActions) = env_nonempty("DOCUMENTER_KEY") ? SSH : HTTPS function authenticated_repo_url(cfg::GitHubActions) return "https://$(ENV["GITHUB_ACTOR"]):$(ENV["GITHUB_TOKEN"])@github.com/$(cfg.github_repository).git" end From 027c92ab5b54fa2f85e4245f5064ab9229ebaf5a Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 15 Feb 2021 10:55:45 +1300 Subject: [PATCH 8/9] Just warn if doctest() fails to clean up (#1526) (cherry picked from commit 6ad949cd79acf63f267c70d99e365abb682661c5) --- CHANGELOG.md | 4 ++++ src/Documenter.jl | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ed9d09142..05b259623c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Version `v0.26.2` +* ![Enhancement][badge-enhancement] `doctest()` no longer throws an error if cleaning up the temporary directory fails for some reason. ([#1513][github-1513], [#1526][github-1526]) + * ![Bugfix][badge-bugfix] Script-type doctests that have an empty output section no longer crash Documenter. ([#1510][github-1510]) * ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511]) @@ -734,10 +736,12 @@ [github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497 [github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510 [github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511 +[github-1513]: https://github.com/JuliaDocs/Documenter.jl/issues/1513 [github-1516]: https://github.com/JuliaDocs/Documenter.jl/issues/1516 [github-1518]: https://github.com/JuliaDocs/Documenter.jl/pull/1518 [github-1519]: https://github.com/JuliaDocs/Documenter.jl/pull/1519 [github-1520]: https://github.com/JuliaDocs/Documenter.jl/pull/1520 +[github-1526]: https://github.com/JuliaDocs/Documenter.jl/pull/1526 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/src/Documenter.jl b/src/Documenter.jl index 1f4ee0a8b2..8405a1cede 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -825,7 +825,11 @@ function doctest( @error "Doctesting failed" exception=(err, catch_backtrace()) false finally - rm(dir; recursive=true) + try + rm(dir; recursive=true) + catch e + @warn "Documenter was unable to clean up the temporary directory $(dir)" exception = e + end end end @testset "$testset" begin From 083f5922584755c057b5802098007118d84f8963 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 15 Feb 2021 14:28:32 +1300 Subject: [PATCH 9/9] A few PDF improvements (#1527) Ref: #1342 1. Use the `oneside` option of the memoir class, which is better for reading on a screen and anything that isn't a bound book. 2. For now hardcode ToC depth to section. 3. Clear page after the title. (cherry picked from commit f7c79297b4d850bc8ec2f2b6eea8fbc941013b4c) --- CHANGELOG.md | 4 ++++ src/Writers/LaTeXWriter.jl | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05b259623c..fdf07c7203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * ![Enhancement][badge-enhancement] `doctest()` no longer throws an error if cleaning up the temporary directory fails for some reason. ([#1513][github-1513], [#1526][github-1526]) +* ![Enhancement][badge-enhancement] Cosmetic improvements to the PDF output. ([#1342][github-1342], [#1527][github-1527]) + * ![Bugfix][badge-bugfix] Script-type doctests that have an empty output section no longer crash Documenter. ([#1510][github-1510]) * ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511]) @@ -694,6 +696,7 @@ [github-1337]: https://github.com/JuliaDocs/Documenter.jl/issues/1337 [github-1338]: https://github.com/JuliaDocs/Documenter.jl/issues/1338 [github-1339]: https://github.com/JuliaDocs/Documenter.jl/pull/1339 +[github-1342]: https://github.com/JuliaDocs/Documenter.jl/issues/1342 [github-1344]: https://github.com/JuliaDocs/Documenter.jl/issues/1344 [github-1345]: https://github.com/JuliaDocs/Documenter.jl/pull/1345 [github-1349]: https://github.com/JuliaDocs/Documenter.jl/pull/1349 @@ -742,6 +745,7 @@ [github-1519]: https://github.com/JuliaDocs/Documenter.jl/pull/1519 [github-1520]: https://github.com/JuliaDocs/Documenter.jl/pull/1520 [github-1526]: https://github.com/JuliaDocs/Documenter.jl/pull/1526 +[github-1527]: https://github.com/JuliaDocs/Documenter.jl/pull/1527 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/src/Writers/LaTeXWriter.jl b/src/Writers/LaTeXWriter.jl index ed6f3a2b26..03fe3d495e 100644 --- a/src/Writers/LaTeXWriter.jl +++ b/src/Writers/LaTeXWriter.jl @@ -214,11 +214,13 @@ function writeheader(io::IO, doc::Documents.Document) isfile(custom) ? cp(custom, "custom.sty"; force = true) : touch("custom.sty") preamble = """ - \\documentclass{memoir} + \\documentclass[oneside]{memoir} \\usepackage{./documenter} \\usepackage{./custom} + \\settocdepth{section} + \\title{ {\\HUGE $(doc.user.sitename)}\\\\ {\\Large $(get(ENV, "TRAVIS_TAG", ""))} @@ -229,6 +231,7 @@ function writeheader(io::IO, doc::Documents.Document) \\frontmatter \\maketitle + \\clearpage \\tableofcontents \\mainmatter