Comments (4)
Commenting every module seems excessive though. Would you verify at least one was documented?
module MyApp
module SomeOtherNesting
# My great comment
class Blah
end
end
end
That said, I haven't found module documentation on namespacing modules particularly useful in understanding a system. There's no good single place for it, and it's usually pretty obvious from the name its purpose.
The mixin case could benefit:
module MyMixin
def hello
end
end
But I don't see a reliable way to check for it.
(Closing because there's no clear next action, but do reopen for more discussion if you like)
from cane.
That said, I haven't found module documentation on namespacing modules particularly useful in understanding a system.
In general, modules that just act as namespaces don't need documentation. I agree with that. Maybe this is just my style of development...but I'd estimate that I use modules for other things far more often than as namespaces. Besides the mixin example you gave, module Foo; extend self; end
is my go-to ruby idiom for globally named singleton objects that I don't want to be instantiatable. I'd estimate that I probably only use modules as namespaces about 1/3 of the time.
So...even though I agree that documenting modules-as-namespaces is generally over kill, on my projects, I'd rather have the occasional doc comment on a module namespace in exchange for the added confidence that cane gives me that my other uses of modules have at least a minimal documentation comment.
Seems like maybe it could be a config option?
from cane.
My general rule of thumb is that I'll document modules only when they contain methods. If all they're used for is namespacing, and contain other class/module declarations only I don't think they need to be documented.
I also think if the module with-a-method occurs multiple times in the codebase (say it's being used to contain methods_and_ namespacing other classes in other source files), then I only have to document it once. Usually I would locate the documentation with the place where the module contains the methods. I know some linters and tools expect that every occurrence of the module comes with documentation, which is just silly imho.
from cane.
It would be possible to only flag modules with methods, though the existing check would need some serious modification (it currently just does a grep, would now require some parsing). I'd accept a pull request matching @dkubb's outline.
from cane.
Related Issues (20)
- Can I get write access?
- Ruby 3 incompatibility (call to `File.exists?`)
- HTML generated output HOT 3
- New vs. Old Hash syntax HOT 1
- Review guard-cane HOT 2
- Vim plugin HOT 4
- value "class" raises exception in multiline definition of array using %w HOT 3
- Classes with no methods still require a comment if they are defined within a class HOT 2
- Consider switching to Parser? HOT 2
- JsonFormatter not working from rake task
- Invalid byte sequence in UTF-8 (ArgumentError) HOT 1
- Allow Cane::RakeTask to pick up .cane files in subdirectories HOT 1
- License missing from gemspec HOT 1
- Global .cane file HOT 2
- Recursively run cane over a directory of files HOT 5
- Load .cane files when scanning subdirectories
- Rspec integration in spec_helper.rb HOT 1
- feature request: alert on no newline at end of file HOT 1
- bug: stack level too deep HOT 2
- bug: stack level too deep (with repro) HOT 11
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 cane.