Docstring for existing functions

I have a function that is called view but does not provide a view on an array.

Unfortunately, the help on this function starts with the documentation of the build-in view and only adds my docstring later. Since the general view docstring is not relevant, I would like to disable it.

Example below (showing the full docstring, I only need the documentation below the separator line). Is there a way to disable re-using?

julia> import Damask

help?> Damask.view
  view(A, inds...)

  Like getindex, but returns a lightweight array that lazily references (or is effectively a
  view into) the parent array A at the given index or indices inds instead of eagerly
  extracting elements or constructing a copied subset. Calling getindex or setindex! on the
  returned value (often a SubArray) computes the indices to access or modify the parent
  array on the fly. The behavior is undefined if the shape of the parent array is changed
  after view is called because there is no bound check for the parent array; e.g., it may
  cause a segmentation fault.

  Some immutable parent arrays (like ranges) may choose to simply recompute a new array in
  some circumstances instead of returning a SubArray if doing so is efficient and provides
  compatible semantics.

  โ”‚ Julia 1.6
  โ”‚
  โ”‚  In Julia 1.6 or later, view can be called on an AbstractString, returning a
  โ”‚  SubString.

  Examples
  โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  julia> A = [1 2; 3 4]
  2ร—2 Matrix{Int64}:
   1  2
   3  4
  
  julia> b = view(A, :, 1)
  2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
   1
   3
  
  julia> fill!(b, 0)
  2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
   0
   0
  
  julia> A # Note A has changed even though we modified b
  2ร—2 Matrix{Int64}:
   0  2
   0  4
  
  julia> view(2:5, 2:3) # returns a range as type is immutable
  3:4

  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

  view(obj::Result; <keyword arguments>)

  Return a copy of obj with the selected view. True or "*" as keyword value selects all.
  False or String[] as keyword value deselects all.

  Arguments
  โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

    โ€ข  obj::HDF_Obj : HDF5_obj to create a view of

    โ€ข  increments::Union{Int,Vector{Int},String,Vector{String},Bool,Nothing}=nothing :
       Number(s) of increments to select. Negative Integers allowed eg. -1 for last
       increment, -2 for second last. Defaults to all.

    โ€ข  times::Union{<:AbstractFloat,Vector{<:AbstractFloat},String,Vector{String},Bool,Nothing}=nothing,
       : Simulation time(s) of increments to select. Defaults to all. Mutually
       exclusive to increments.

    โ€ข  phases::Union{String,Vector{String},Bool,Nothing}=nothing, : Name(s) of phases
       to select. Defaults to all.

    โ€ข  homogenizations::Union{String,Vector{String},Bool,Nothing}=nothing,: Name(s) of
       homogenizations to select. Defaults to all.

    โ€ข  fields::Union{String,Vector{String},Bool,Nothing}=nothing, : Name(s) of fields
       to select. Defaults to all.

    โ€ข  protected::Union{Bool,Nothing}=nothing : Protection status of existing data.

  Examples
  โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  Create a view on the last increment

  julia> using Damask
  julia> res = read_HDF5("my_file.hdf5")
  julia> v = view(res,increments = -1)

This happens because your package is adding a method to Base.view rather than defining an independent function Damask.view. This is a consequence of the import statement here: https://github.com/eisenforschung/Damask.jl/blob/1c82912020acdadf983d1a8dfbb158a65f7c0219/src/Damask.jl#L3. If you want Damask.view to be a separate function from Base.view you should remove this import (similarly for Damask.get and Base.get).

3 Likes