I use a package called SVGO to minify svg files like many others. Unfortunately when it minifies it generates generic id's that cause issues when you inline them on the same page as they use the same id.
In comes the plugin in question, it's supposed to fix this issue by prefixing the id's so they're unique and wont overwrite each other.
Problem is, I have no idea how it works. It says
Usage
new SVGO({
plugins: [{
uniqueID: require('svgo-unique-id'),
}]
})
Now I don't know if I'm supposed to add this anywhere, if it's automatically added, if I need to create a new file for this or anything.
So my question really is, how do I go about using this. I think it should be straight forward but I've never used a plugin for a package before so I don't know anything about how it works.
Any pointers are much appreciated.
I'm using Prettier in VSCode, but it appears to be flagging mistakes that I think are ok.
Specifically, if I test a variable like:
if (myObject?.property1?.property2) {
....
}
(Not sure of the correct name for using questions marks like this) then it flags the question marks as invalid.
I can see there is an ecmaVersion setting in .prettierrc but this doesn't seem to do anything, and anyway, as I understand it, Node versions don't exactly follow ECMA versions anyway.
What can I do to make Prettier correctly lint my code?
I am dying here on lazily loading modules into angular-meteor 1.5.
So the Meteor Version is 1.4.2.3, meaning with ES2015, import, ui-router etc.
So far I've tried ocLazyLoad, angularAMD has a completely different syntax (with define(function()...) which I don't know how to "merge" with the Boilerplate App of Urigo's angular-meteor.
So in ocLazyLoad, I went by this https://github.com/alo/oclazyload-uirouter-component-routing-tests github example, since it is the only one I've found that has the ng 1.5 components and submodules instead of just lazily adding controllers to the main apps module.
When I try to implement this, ocLazyLoad logs that the js-file is loaded, but in the Sources-tab instead of the actual file, the js-file contains the whole meteor app.
Any idea on why that is or whether angularAMD works with angular-meteor or in general, how to make lazyLoading modules work?
It's not as natural as it should be because meteor doesn't support lazy loading yet. But here is a working solution:
If your are trying to use lazy loading on routes like this:
{ path: "myPath", loadChildren: "app/myModule/myModule.module#MyModule"}
You should use instead a callback to get the module using ES5 callbacks.
{path: "myPath", loadChildren: ()=> require('./myModule/myModule.module')["MyModule"] }
Hopefully will work for you as well. :)
Question answered on my post
I just sent this to Alexis Sellier <self#cloudhead.net> but it bounced back, prompting me to seek answers here:
Hi Alexis,
First and foremost, thanks for a great Java support for the lesscss library!
I am and have been for a while on version 1.7.0.1.1.
I was attempting to use the extend feature which worked when used as:
.button-a {
&:extend(.button-base);
.rounded-corners-top(7px);
}
but not when used as
.button-a:extend(.button-base) {
.rounded-corners-top(7px);
}
further more, the first case does not work if button-base well looks like this:
.button-base {
...
&:hover {
background-color: white;
color: #ff3c1f;
}
}
The hover stuff never gets active from extended contexts. Does this work in the JS version?
I tried to peek into the java package and it seems you have merged
what I believe to be the JS library with some other Rhino JS code,
making it hard to upgdrade to the latest JS version.
It is not clear from the Java library what version is being used either.
I have myself written another js library and successfully used Rhino,
EnvJS and my JS library, and I choose to approach it a bit
differently, namely that the JS can be supplied separately, as an
argument to my java class which takes care of merging it all.
Is that something you think is possible? If not, how up to date with
the JS code is the current Java version?
What limitations do you see in going the approach I've mentioned above.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm currently using JSDoc Toolkit to document my code, but it doesn't quite fit - namely, it seem to struggle with describing namespaces properly. Say you have two simple classes in each their files:
lib/database/foo.js:
/** #class */
function Foo(...) {...}
/** #function ... */
Foo.prototype.init(..., cb) { return cb(null, ...); };
module.exports = foo;
And then something inherited lib/database/bar.js:
var Foo = require('./foo');
/**
* #class
* #augments Foo
*/
function Bar(....) {...}
util.inherits(Bar, Foo);
Bar.prototype.moreInit(..., cb) { return cb(null, ...); };
In the generated documentation, this is output simply as Foo and Bar, without the leading database (or lib.database), which are quite necessary when you don't have everything in a global scope.
I've tried throwing #namespace database and #name database.Foo at it, but it doesn't turn out nice.
Any ideas for making JSDoc output something more suitable, or some entirely different tool that works better with Node.js? (I looked briefly at Natural Docs, JSDuck and breezed over quite a few others that looked quite obsolete...)
JSDoc is a port of JavaDoc. So basically the documentation assumes classical OOP and that's not suited to JavaScript.
Personally I would recommend using docco to annotate your source code. Examples of it can be found for underscore, backbone, docco.
A good alternative to docco is groc
As for an actual API documentation, I personally find auto generated documentation from comments just does not work for JavaScript and recommend you hand-write your API documentation.
Examples would be underscore API, Express API, nodejs API, socket.io docs
Similar StackOverFlow questions
Generating Javascript documentation
YUIDoc is a Node.js application that generates API documentation from comments in source, using a syntax similar to tools like Javadoc and Doxygen. YUIDoc provides:
Live previews. YUIDoc includes a standalone doc server, making it trivial to preview your docs as you write.
Modern markup. YUIDoc's generated documentation is an attractive, functional web application with real URLs and graceful fallbacks for spiders and other agents that can't run JavaScript.
Wide language support. YUIDoc was originally designed for the YUI project, but it is not tied to any particular library or programming language. You can use it with any language that supports /* */ comment blocks.
NOTE: Dox no longer outputs HTML, but a blob of JSON describing the parsed code. This means the code below doesn't work terribly well any more...
We ended up using Dox for now. It is a lot like docco, that Raynos mentions, but thows all of it in one bit HTML-file for output.
We hacked this into our makefiles:
JS_FILES := $(shell find lib/ -type f -name \*.js | grep -v 3rdparty)
#Add node_modules/*/bin/ to path:
#Ugly 'subst' hack: Check the Make Manual section 8.1 - Function Call Syntax
NPM_BINS:=$(subst bin node,bin:node,$(shell find node_modules/ -name bin -type d))
ifneq ($(NPM_BINS),)
PATH:=${NPM_BINS}:${PATH}
endif
.PHONY: doc lint test
doc: doc/index.html
doc/index.html: $(JS_FILES)
#mkdir -p doc
dox --title "Project Name" $^ > $#
It is not the prettiest or most efficient documentation ever made (and dox has quite a few minor bugs) - but I find it work rather well, at least for minor projects.
Sorry, I was not on StackExchange a year ago, but I believe the answer to your original question is to use the #memberOf tag:
/** #namespace */
database = {};
/**
* #class
* #memberOf database
*/
function Foo() { ... };
http://code.google.com/p/jsdoc-toolkit/wiki/TagMemberOf
This tag may or may not have existed when you asked your question.
Found a really nice solution for the problem: doxx.
It uses dox as mentioned above and converts this to nice HTML afterwards. Has a nice usage and worked great for me.
https://github.com/FGRibreau/doxx
I work with JSDoc and is very efficient, in addition to easy, but when projects have many alternate libraries are quite complicated development. I found Groc a very good tool based on Docco and works with other languages like: Python, Ruby, C + +, among others...
Furthermore Groc working with Markdown in GitHub which can be much more efficient when working with git as version control. Further helps assemble pages for publishing on GitHub.
You can also use the task manager GruntJS through grunt-groc example:
Install package:
npm install grunt-groc --save-dev
configure in your task file:
grunt.loadNpmTasks('grunt-groc');
And the config task:
// Project configuration.
grunt.initConfig({
groc: {
coffeescript: [
"coffee/*.coffee", "README.md"
],
options: {
"out": "doc/"
}
}
});
For run task:
grunt.registerTask('doc', ['groc'])