# Function to get docs of a package to open in a browser window?

**URL:** https://discourse.julialang.org/t/function-to-get-docs-of-a-package-to-open-in-a-browser-window/17090
**Category:** General Usage
**Tags:** documentation
**Created:** [November 2, 2018, 4:13pm UTC](https://discourse.julialang.org/t/function-to-get-docs-of-a-package-to-open-in-a-browser-window/17090 "2018-11-02T16:13:31Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [November 3, 2018, 12:35am UTC](https://discourse.julialang.org/t/function-to-get-docs-of-a-package-to-open-in-a-browser-window/17090/12 "2018-11-03T00:35:33Z")

</div>

I define this macro. It’s useful sometimes:

```julia
readreadme(mod::Module) = readreadme(Base.PkgId(mod))

function readreadme(pkg::Base.PkgId)
    path = joinpath(dirname(dirname(Base.locate_package(pkg))), "README.md")
    return Markdown.parse_file(path)
end

"""
    @readreadme module

Read README.md of `module`.
"""
macro readreadme(ex)
    quote
        mod = try
            $(esc(ex))
        catch err
            err isa UndefVarError || rethrow()
            nothing
        end
        if mod === nothing
            readreadme(Base.identify_package($(string(ex))))
        else
            readreadme(mod)
        end
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/function-to-get-docs-of-a-package-to-open-in-a-browser-window/17090)._
