# Listing Commands in a Module

I was looking to narrow a bulk \tab complete to just the commands in a certain package and found this which works for any defined package.

``````julia> Cmd.\tab
abstract         isdispatchtuple   mutable           size
hasfreetypevars  isinlinealloc     name              super
instance         layout            names             types
isbitstype       llvm::DIType      ninitialized      uid
isconcretetype   llvm::StructType  parameters        zeroinit

``````

It didn’t seem to be mentioned anywhere obvious. Maybe not that thrilling to most.

1 Like

You may find this useful:

https://docs.julialang.org/en/v1/stdlib/REPL/#Tab-completion-1

There are many clever completions.

1 Like

What’s missing is a feature to display only exported names of a package, or the ability to make unneeded names private or hidden.

1 Like

You can at least hide methods by overwriting `propertynames`.

1 Like

While it’s easy to get out of date, I encourage package authors to provide convenient API summaries by attaching a docstring to the module itself. For example:

``````julia> using Images

help?> Images
search: Images ImageSemiMetric nimages ImageDistances ImageAxes ImageTransformations ImageMeta ImageCore ImageMetric ImageMetadata ImagePreMetric ImageFiltering ImageMorphology integral_image

Constructors, conversions, and traits:

- Construction: use constructors of specialized packages, e.g., `AxisArray`, `ImageMeta`, etc.
- "Conversion": `colorview`, `channelview`, `rawview`, `normedview`, `permuteddimsview`
- Traits: `pixelspacing`, `sdims`, `timeaxis`, `timedim`, `spacedirections`

Contrast/coloration:

- `clamp01`, `clamp01nan`, `scaleminmax`, `colorsigned`, `scalesigned`

Algorithms:

- Reductions: `maxfinite`, `maxabsfinite`, `minfinite`, `meanfinite`, `sad`, `ssd`, `integral_image`, `boxdiff`, `gaussian_pyramid`
- Resizing: `restrict`, `imresize` (not yet exported)
- Filtering: `imfilter`, `imfilter!`, `imfilter_LoG`, `mapwindow`, `imROF`, `padarray`
- Filtering kernels: `Kernel.` or `KernelFactors.`, followed by `ando[345]`, `guassian2d`, `imaverage`, `imdog`, `imlaplacian`, `prewitt`, `sobel`
- Exposure : `imhist`, `histeq`, `adjust_gamma`, `histmatch`, `imadjustintensity`, `imstretch`, `imcomplement`, `clahe`, `cliphist`
- Edge detection: `imedge`, `imgradients`, `thin_edges`, `magnitude`, `phase`, `magnitudephase`, `orientation`, `canny`
- Corner detection: `imcorner`,`imcorner_subpixel`, `harris`, `shi_tomasi`, `kitchen_rosenfeld`, `meancovs`, `gammacovs`, `fastcorners`
- Blob detection: `blob_LoG`, `findlocalmaxima`, `findlocalminima`
- Morphological operations: `dilate`, `erode`, `closing`, `opening`, `tophat`, `bothat`, `morphogradient`, `morpholaplace`, `feature_transform`, `distance_transform`, `convexhull`
- Connected components: `label_components`, `component_boxes`, `component_lengths`, `component_indices`, `component_subscripts`, `component_centroids`
- Interpolation: `bilinear_interpolation`

- `shepp_logan```````
7 Likes

In the (good) old days, `?MyPackage` would simply paste the `Readme.md` to the REPL. That doesn’t seem to happen anymore, though? Is this the suggested replacement?

1 Like

With https://github.com/JuliaLang/julia/issues/25930 we could have both. I do think it’s useful to have something that reminds experienced but infrequent users of the names of the relevant methods.

1 Like

I implemented https://github.com/JuliaDocs/DocStringExtensions.jl/pull/68 as a replacement(ish) of that feature, so you can simply do

``````"""
"""
module MyModule
...
end
``````
3 Likes

Nice, so does my package need to depend on `DocStringExtensions` to do this?

Yes, you need a `using DocStringExtensions` inside the package. I’d like to point out that it is an extremely light dependency; it is pure Julia and has no dependencies of its own. It can also be useful to improve other docstrings in your package.

3 Likes

Thanks, that sounds like a great idea.
BTW i’d still think it was great with a function listing the exported functions from a module.

I have missed that feature. It displayed the module doc string if present. It was

``````julia> using HTTP
help?> HTTP
No documentation found.
``````

I wonder why it was removed. Of course the best thing about it is there is almost always a README, seldom a module doc string. Although I agree you should normally include one.

1 Like

I remember thinking that this was a poor idea. Dumping 400 lines of miscellaneous info wasn’t a good experience in the REPL. (And I also remember finding the 400 or so lines of Colors.jl’s README incentive enough to make a new set of Documenter docs…)

1 Like

1 Like

Yes apparently this use case is covered there

``````Tab completion can also help completing fields:

julia> import UUIDs

julia> UUIDs.uuid[TAB]
uuid1        uuid4         uuid_version
``````

There’s `names`:

``````  names(x::Module; all::Bool = false, imported::Bool = false)
``````

Get an array of the names exported by a Module, excluding deprecated names. If all is true, then the list also includes non-exported names defined in the module, deprecated names, and compiler-generated names. If imported is true, then names explicitly imported from other modules are also included.

4 Likes

it’s not documented, but tab completion also works for Dict keys

``````julia> foo=Dict("qwer"=>2, "asdf"=>3)
Dict{String,Int64} with 2 entries:
"asdf" => 3
"qwer" => 2

julia> foo["q[TAB]
``````
3 Likes