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 2 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
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 @@ function fileurl(remote::GitLab, ref::AbstractString, filename::AbstractString,
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
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"
end

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