diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..85e4817 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - '1.0' + - '1' + - 'nightly' + os: + - ubuntu-latest + - windows-latest + - macos-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 + + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + - run: | + julia --project=docs -e ' + using Pkg + Pkg.develop(PackageSpec(path=pwd())) + Pkg.instantiate()' + - run: julia --project=docs --color=yes docs/make.jl + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 65b05cb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: julia - -os: - - linux - - osx - -julia: - - 1.0 - - 1.1 - - 1.2 - - nightly - -# Use the following lines to allow failures on nightly julia -# (tests will run but not make your overall status red) -# matrix: -# allow_failures: -# - julia: nightly - -notifications: - email: false - -jobs: - include: - - stage: "Documentation" - julia: 1.0 - os: linux - script: - - julia --color=yes --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path="."))' - - julia --color=yes --project=docs/ docs/make.jl - after_success: skip - -after_success: - - julia -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' diff --git a/README.md b/README.md index bb40aaf..13ba433 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ *A source code highlighter for Julia.* -| **Documentation** | **Build Status** | -|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:| -| [![][docs-stable-img]][docs-stable-url] [![][docs-latest-img]][docs-latest-url] | [![][travis-img]][travis-url] [![][appveyor-img]][appveyor-url] [![][codecov-img]][codecov-url] | +| **Documentation** | **Build Status** | +|:-------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------:| +| [![][docs-stable-img]][docs-stable-url] [![][docs-latest-img]][docs-latest-url] | ![CI](https://github.com/JuliaDocs/Highlights.jl/workflows/CI/badge.svg) [![][codecov-img]][codecov-url] | + ## Installation @@ -44,12 +45,6 @@ then feel free to ask for help in the [Gitter chat room][gitter-url]. [docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg [docs-stable-url]: https://juliadocs.github.io/Highlights.jl/stable -[travis-img]: https://travis-ci.org/JuliaDocs/Highlights.jl.svg?branch=master -[travis-url]: https://travis-ci.org/JuliaDocs/Highlights.jl - -[appveyor-img]: https://ci.appveyor.com/api/projects/status/qnphq3a8eph3o979/branch/master?svg=true -[appveyor-url]: https://ci.appveyor.com/project/MichaelHatherly/highlights-jl/branch/master - [codecov-img]: https://codecov.io/gh/JuliaDocs/Highlights.jl/branch/master/graph/badge.svg [codecov-url]: https://codecov.io/gh/JuliaDocs/Highlights.jl diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5cc0b88..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,44 +0,0 @@ -environment: - matrix: - - julia_version: 1.0 - - julia_version: 1.1 - - julia_version: 1.2 - - julia_version: nightly - -platform: - - x86 # 32-bit - - x64 # 64-bit - -# Use 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%" - -# # Uncomment to support code coverage upload. Should only be enabled for packages -# # which would have coverage gaps without running on Windows -# on_success: -# - echo "%JL_CODECOV_SCRIPT%" -# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%" diff --git a/src/lexers/julia.jl b/src/lexers/julia.jl index 563047c..37118a7 100644 --- a/src/lexers/julia.jl +++ b/src/lexers/julia.jl @@ -90,7 +90,8 @@ julia_is_triple_string_macro(ctx::Context) = julia_is_string_macro(ctx, 3) (julia_is_symbol, STRING_CHAR), (r"\b(? "]", ) +tokentest( + Lexers.JuliaLexer, + "a[begin]", + NAME => "a", + PUNCTUATION => "[", + KEYWORD => "begin", + PUNCTUATION => "]", +) + +tokentest( + Lexers.JuliaLexer, + "a[begin:end]", + NAME => "a", + PUNCTUATION => "[", + KEYWORD => "begin", + OPERATOR => ":", + KEYWORD => "end", + PUNCTUATION => "]", +) + +tokentest( + Lexers.JuliaLexer, + "a[begin-1]", + NAME => "a", + PUNCTUATION => "[", + KEYWORD => "begin", + OPERATOR => "-", + NUMBER_INTEGER => "1", + PUNCTUATION => "]", +) + tokentest( Lexers.JuliaLexer, "(1,2.0)", @@ -254,6 +285,43 @@ tokentest( KEYWORD => "end", ) +tokentest( + Lexers.JuliaLexer, + "struct Empty{T} where T <: S end", + KEYWORD => "struct", + TEXT => " ", + NAME_FUNCTION => "Empty", + PUNCTUATION => "{", + NAME => "T", + PUNCTUATION => "}", + TEXT => " ", + KEYWORD_PSEUDO => "where", + TEXT => " ", + NAME => "T", + TEXT => " ", + OPERATOR => "<:", + TEXT => " ", + NAME => "S", + TEXT => " ", + KEYWORD => "end", +) + +tokentest( + Lexers.JuliaLexer, + "primitive type Float16 <: AbstractFloat 16 end", + KEYWORD => "primitive type", + TEXT => " ", + NAME => "Float16", + TEXT => " ", + OPERATOR => "<:", + TEXT => " ", + NAME => "AbstractFloat", + TEXT => " ", + NUMBER_INTEGER => "16", + TEXT => " ", + KEYWORD => "end", +) + tokentest( Lexers.JuliaLexer, """ diff --git a/test/samples/julia b/test/samples/julia index 8f9f609..709f9cf 100644 --- a/test/samples/julia +++ b/test/samples/julia @@ -11,6 +11,9 @@ Multiline comments... [1, 3, 3, 4][1:end] (1, 2, 1.0)[1:2] [(1, 3), (3, 4)][end - 1] +[(1, 3), (3, 4)][begin] +[(1, 3), (3, 4)][begin:2] +[(1, 3), (3, 4)][begin:end] # Keywords. if x in y @@ -29,9 +32,9 @@ end module M end baremodule M end -typealias T A -abstract A <: T -type Point{T} +const T = A +abstract type A <: T end +mutable struct Point{T} where T <: Number x::T y::T @@ -42,7 +45,9 @@ type Point{T} end end -immutable Empty{T} end +struct Empty{T} end + +primitive type Float16 <: AbstractFloat 16 end macro something(x...) # ...