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

Add AzureDevOps remote #2356

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## UNRELEASED

### Added

* Documenter now includes `Remotes.AzureDevOps`, to support repositories hosted on Azure DevOps. ([#2356])

### Changed

* `id` anchors may now start with a numeric digit. ([#744], [#2325])
Expand Down
3 changes: 2 additions & 1 deletion docs/src/lib/remote-links.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Note that enabling this option can cause documentation builds to fail due to net

!!! note

The [`Remotes` API](@ref remotes-api) can be used to implement the methods to compute the remote URLs (for now, Documenter only supports [GitHub](@ref Remotes.GitHub) and [GitLab](@ref Remotes.GitLab) natively).
The [`Remotes` API](@ref remotes-api) can be used to implement the methods to compute the remote URLs (for now, Documenter only supports [GitHub](@ref Remotes.GitHub), [GitLab](@ref Remotes.GitLab) and [AzureDevOps](@ref Remotes.AzureDevOps) natively).

[^1]: There is an exception to this: links to Julia `Base` module source files.
But Documenter already known how to handle those correctly, and they are really only relevant to the Julia main manual build.
Expand Down Expand Up @@ -84,6 +84,7 @@ The rules are as follows:
Documenter.Remotes
Documenter.Remotes.GitHub
Documenter.Remotes.GitLab
Documenter.Remotes.AzureDevOps
```

The following types and functions and relevant when creating custom
Expand Down
30 changes: 30 additions & 0 deletions src/utilities/Remotes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,36 @@
end
issueurl(remote::GitLab, issuenumber) = "$(repourl(remote))/-/issues/$issuenumber"


"""
AzureDevOps(organisation :: AbstractString, project :: AbstractString, repo :: AbstractString)

Represents a remote Git repository hosted on Azure DevOps. The repository is identified by the
name of the organization, the project and the repository. E.g.:

```julia
makedocs(
repo = AzureDevOps("my-org", "my-project", "my-repository")
)
```
"""
struct AzureDevOps <: Remote
organisation::String
project::String
repo::String
end
repourl(remote::AzureDevOps) = "https://dev.azure.com/$(remote.organisation)/$(remote.project)/_git/$(remote.repo)"
function fileurl(remote::AzureDevOps, ref::AbstractString, filename::AbstractString, linerange)
ref = format_commit(ref, RepoAzureDevOps)
url = repourl(remote) * "?path=/$filename&version=$ref"
if isnothing(linerange)
return url

Check warning on line 199 in src/utilities/Remotes.jl

View check run for this annotation

Codecov / codecov/patch

src/utilities/Remotes.jl#L194-L199

Added lines #L194 - L199 were not covered by tests
end
# To highlight one line, go to the start of the next (lineEndColumn is set to 1 in url above)
# It doesn't matter if lineEnd exceeds the number of lines in the file
return url * "&line=$(first(linerange))&lineEnd=$(last(linerange)+1)&lineStartColumn=1&lineEndColumn=1"

Check warning on line 203 in src/utilities/Remotes.jl

View check run for this annotation

Codecov / codecov/patch

src/utilities/Remotes.jl#L203

Added line #L203 was not covered by tests
end

############################################################################
# Handling of URL string templates (deprecated, for backwards compatibility)
#
Expand Down
Loading