# Listing Commands in a Module

**URL:** <https://discourse.julialang.org/t/listing-commands-in-a-module/17632>\
**Category:** New to Julia\
**Created:** [November 17, 2018, 5:14am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632 "2018-11-17T05:14:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver/32/19264_2.png) [@oliver](https://discourse.julialang.org/u/oliver)\
**Post date:** [November 17, 2018, 5:14am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/1 "2018-11-17T05:14:00Z")

</div>

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
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.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 17, 2018, 8:57am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/2 "2018-11-17T08:57:49Z")

</div>

You may find this useful:

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

There are many clever completions.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [November 17, 2018, 11:01am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/3 "2018-11-17T11:01:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [November 17, 2018, 11:26am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/4 "2018-11-17T11:26:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 17, 2018, 11:49am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/5 "2018-11-17T11:49:09Z")

</div>

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
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`
  - Gradients: `backdiffx`, `backdiffy`, `forwarddiffx`, `forwarddiffy`, `imgradients`
  - 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`

  Test images and phantoms (see also TestImages.jl):

  - `shepp_logan`
```

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 17, 2018, 11:57am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/6 "2018-11-17T11:57:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 17, 2018, 12:05pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/7 "2018-11-17T12:05:19Z")

</div>

With [https://github.com/JuliaLang/julia/issues/25930](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.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 17, 2018, 1:02pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/8 "2018-11-17T13:02:35Z")

</div>

> [@mkborregaard](#):
>
> 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?

I implemented [Add README and LICENSE by fredrikekre · Pull Request #68 · JuliaDocs/DocStringExtensions.jl · GitHub](https://github.com/JuliaDocs/DocStringExtensions.jl/pull/68) as a replacement(ish) of that feature, so you can simply do

```julia
"""
$(README)
"""
module MyModule
...
end

```

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 17, 2018, 1:34pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/9 "2018-11-17T13:34:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 17, 2018, 1:57pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/10 "2018-11-17T13:57:39Z")

</div>

> [@mkborregaard](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 17, 2018, 3:10pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/11 "2018-11-17T15:10:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [November 17, 2018, 3:32pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/12 "2018-11-17T15:32:11Z")

</div>

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

```julia
julia> using HTTP
help?> HTTP
  No documentation found.
  Displaying the README.md for the module instead. ...

```

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.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [November 17, 2018, 4:05pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/13 "2018-11-17T16:05:00Z")

</div>

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…)

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 17, 2018, 4:09pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/14 "2018-11-17T16:09:22Z")

</div>

> [@mkborregaard](#):
>
> BTW i’d still think it was great with a function listing the exported functions from a module.

[https://juliadocs.github.io/DocStringExtensions.jl/latest/#DocStringExtensions.EXPORTS](https://juliadocs.github.io/DocStringExtensions.jl/latest/#DocStringExtensions.EXPORTS)

---

<div class="post-metadata">

**Author:** ![oliver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver/32/19264_2.png) [@oliver](https://discourse.julialang.org/u/oliver)\
**Post date:** [November 17, 2018, 5:34pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/15 "2018-11-17T17:34:59Z")

</div>

> [@Tamas\_Papp](#):
>
> You may find this useful:
> 
> [https://docs.julialang.org/en/v1/stdlib/REPL/#Tab-completion-1](https://docs.julialang.org/en/v1/stdlib/REPL/#Tab-completion-1)
> 
> There are many clever completions.

Yes apparently this use case is covered there

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

julia> import UUIDs

julia> UUIDs.uuid[TAB]
uuid1 uuid4 uuid_version

```

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [November 17, 2018, 5:42pm UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/16 "2018-11-17T17:42:29Z")

</div>

There’s `names`:

> ```julia
> 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.

---

<div class="post-metadata">

**Author:** ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)\
**Post date:** [November 25, 2018, 4:31am UTC](https://discourse.julialang.org/t/listing-commands-in-a-module/17632/17 "2018-11-25T04:31:24Z")

</div>

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

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

julia> foo["q[TAB]

```
