-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Documenting fictive or external methods/classes (ex: configatron) #1153
Comments
* moved markdown documentation to pages/ folder * use configatron for global config * documentation configuration in a markdown file until this issue is solved: lsegal/yard#1153
You can use
There are many. You can use the As far as documenting configuration from configatron, there are lots of different ways to do this, and the answer depends very much on what kind of information you're trying to expose. You could write a YARD extension to parse assignments against If you want a design opinion, the abstractions provided by configatron.NVDFeedScraper.feed.default_storage_location = '/tmp'
class NVDFeedScraper
# @!attribute default_storage_location
# @!scope class
# @return [String] the default location for feed data. Defaults to `/tmp`.
class Feed
def self.default_storage_location
configatron.NVDFeedScraper.feed.default_storage_location
end
def self.default_storage_location=(v)
configatron.NVDFeedScraper.feed.default_storage_location = v
end
end
end This will get documented as a class attribute on And then, if you wanted to, you could at any point in the future transparently move away from configatron on the backend with a simple code swap: class NVDFeedScraper
class Feed
class << self
# @return [String] the default location for feed data. Defaults to `/tmp`.
attr_accessor :default_storage_location
end
@default_storage_location = '/tmp'
end
end Hope that helps! |
My bad, the doc was confusing, so this is in an error in the doc?
I read the documentation of
This is a very good advice, thanks.
That helps a lot, thank you again. |
Context
For configuration I use configatron gem in my project.
Questions
How can I use YARD to properly document config parameter from configatron directly in my source code? (because configatron does not appear as a class or a method)
More generally, is there a way to document fictive or external ruby methods/classes?
Workaround
The workaround I'm using right now is to create a makrdown file
pages/CONFIGURATION.md
, document it in pure markdown, and then in my code refer to it with a YARD file link{file:pages/CONFIGURATION.md Configuration}
.Workaround Issue
But even this workaround is not suitable and show a second issue with YARD file link.
Linking Files with
{file:...}
is a problem for markdown file because you can only provide an alias but not anchors as for HTML files.So you can't use something like
{file:pages/CONFIGURATION.md Configuration#anchor_id}
. Because if I set 200 parameters with configatron and I'm not able to refer to anchors in my markdown file people reading the documentation will be lost.More questions
If there are no proper way to document fictive or external ruby methods/classes, do I need to open an issue for this?
Do I need to open an issue for YARD file link
{file:}
not supporting anchors for markdown files?Environment details:
ruby -v
): ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]yard -v
): yard 0.9.12I have read the Contributing Guide.
The text was updated successfully, but these errors were encountered: