Comments (2)
I have an update on this that seems to be working but is also pretty hacky. I realized that the problem I was having was that the docstring for my type occurred before the data necessary for the abbreviation was available. In other words the following example wouldn't be able to grab info from get_doc
(what I'm doing is a lot more complex but this is the closest to a MWE I could get).
"""
MyType
$(MYABBREVIATION)
"""
struct MyType end
get_doc(::MyType) = "some documentation")
What I do later is similar to
d = @doc MyType
first(d.meta[:results]).object = nothing
I think the reason this works is because when parsedoc
is called it doesn't actually parse the docstring unless docstring.object === nothing
. So this forces it to parse the docstring again.
This seems like a pretty unsafe solution though and it would be cool if there was a way to work around this safely.
from docstringextensions.jl.
We don't have any publicly defined API for this purpose, but if you or someone else would like to take a stab at designing and implementing it, I think it would be a good addition to the package.
I think the reason this works is because when
parsedoc
is called it doesn't actually parse the docstring unlessdocstring.object === nothing
. So this forces it to parse the docstring again.
This is correct -- the parsed docstring gets cached. However, the caching only happens when you try do look up the docstring, e.g. in the REPL. So if your custom abbreviation is registered before that happens, like during the parsing of your package/module, it should work.
from docstringextensions.jl.
Related Issues (20)
- How to use alias of AbstractArray instead of the full name? (Feature request) HOT 2
- Display parametric types in a better way? HOT 2
- Remove documentation page for v0.1
- Update CI badges in the README HOT 2
- TagBot trigger issue HOT 7
- The `TYPES` template does not apply to parametric types
- MODULES key not found for `@template` HOT 1
- Doctest failures
- Format docstrings HOT 4
- Considering writing a script to add function signatures to a code base. HOT 5
- Examples of how to use all of the functionality HOT 5
- expected test failure from the incoming `Core.Compiler` changes HOT 3
- Cannot get source for generated functions
- feature request: non-api doc marker HOT 7
- How to show default values and types of keyword arguments? HOT 1
- Update docs to latest version of Documenter HOT 5
- different abbreviations for concrete and abstract types HOT 1
- FUNCTIONNAME inside a function that generates the docstring HOT 7
- Would it be possible to add a TYPEDMETHODLIST abbreviation HOT 2
- Internal errors when (ab)using `@template` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docstringextensions.jl.