Skip to content

Commit

Permalink
expand doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Oct 30, 2023
1 parent 9cd272f commit 18b1bce
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/attribute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,45 @@ function show_attrib(io,a)
end


"""
Base.keys(a::Attributes)
Return a list of the names of all attributes.
"""
Base.keys(a::Attributes) = attribnames(a.ds)


"""
getindex(a::Attributes,name::SymbolOrString)
Return the value of the attribute called `name` from the
attribute list `a`. Generally the attributes are loaded by
indexing, for example:
```julia
using NCDatasets
ds = NCDataset("file.nc")
title = ds.attrib["title"]
```
"""
Base.getindex(a::Attributes,name) = attrib(a.ds,name)


"""
Base.setindex!(a::Attributes,data,name::SymbolOrString)
Set the attribute called `name` to the value `data` in the
attribute list `a`. `data` can be a vector or a scalar. A scalar
is handeld as a vector with one element in the NetCDF data model.
Generally the attributes are defined by indexing, for example:
```julia
ds = NCDataset("file.nc","c")
ds.attrib["title"] = "my title"
close(ds)
```
"""
Base.setindex!(a::Attributes,data,name) = defAttrib(a.ds,name,data)

Check warning on line 102 in src/attribute.jl

View check run for this annotation

Codecov / codecov/patch

src/attribute.jl#L102

Added line #L102 was not covered by tests

Base.show(io::IO,a::Attributes) = show_attrib(io,a)
10 changes: 9 additions & 1 deletion src/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"""
CommonDatamodel.dimnames(ds::AbstractDataset)
Return an iterable of all dimension names in `ds`.
Return an iterable of all dimension names in `ds`. This
information can also be accessed using the property `ds.dim`:
# Examples
```julia
ds = NCDataset("results.nc", "r");
dimnames = keys(ds.dim)
```
"""
dimnames(ds::Union{AbstractDataset,AbstractVariable}) = ()

Expand Down

0 comments on commit 18b1bce

Please sign in to comment.