How do I document a module where module.exports is a function? - jsdoc

I'm trying to document a node module that exports a function, but I'm not getting any reference to the function in my jsdocs output.
The output, using the default template, Just looks like this:
Module: testModule
With nothing under the heading.
Here's what I've tried so far:
try 1
/**
* #module testModule
*/
'use strict';
/**
* #function module:testModule
* #param {String} x Log string
*/
module.exports = function(x) {
console.log(x);
};
try 2
/**
* #module testModule
*/
'use strict';
/**
* #param {String} x Log string
*/
module.exports = function(x) {
console.log(x);
};

Well, this seems like a bug, but I found a work around.
It will only work if you include a description. Like this:
/**
* #module testModule
*/
'use strict';
/**
* Some Description
*
* #function module:testModule
* #param {String} x Log string
*/
module.exports = function(x) {
console.log(x);
};

Related

How does one reference a module as a param in JSDocs

Given a module like:
/** Config module
* #module Config
*/
export default class Config {
...
How do I specify a link to the Config module when specified as a param?
/**
* Foo
* #module Foo
*/
export default class Foo {
/**
* Create a new instance
* #constructor
* #param {Config} config - the config
*/
constructor(config) {
this.config = config;
}
I cannot seem to get the Config to register as a link
Simple prefix with module:
See below
/**
* Foo
* #module Foo
*/
export default class Foo {
/**
* Create a new instance
* #constructor
* #param {module:Config} config - the config
*/
constructor(config) {
this.config = config;
}

Send Email from Laravel Commands and Scheduler

I'm trying to make a scheduled task using commands but does not work MailFacade to send emails.
The Command Class:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class ToDoUserAlert extends Command
{
/**
* The name and signature of the console command.
*
* #var string
*/
protected $signature = 'toDoAlert';
/**
* The console command description.
*
* #var string
*/
protected $description = 'Send ToDo user alerts by email';
/**
* Create a new command instance.
*
* #return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* #return mixed
*/
public function handle()
{
Mail::raw(date('Y-m-d').' '.date('H:i'), function ($message) {
$message->to('sairam.santana#gmail.com');
$message->subject('Reminder Notification');
});
}
}
Kerner:
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* #var array
*/
protected $commands = [
Commands\ToDoUserAlert::class,
];
/**
* Define the application's command schedule.
*
* #param \Illuminate\Console\Scheduling\Schedule $schedule
* #return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('toDoAlert')->everyMinute();
}
}

babel Cli inline attribute not working on babel-cli

I'm trying to use inline attribute declaration. the code below works fine on babelJs website (Experimental option input is checked) but it doesn't work using babel-cli. expect to log inlineAttribute.
/**
* Created by Ala on 25/02/2016.
*/
/**
* Class Human
*/
class Human{
inlineAttribute = 60;
/**
* #constructor
* #param name
*/
constructor(name){
this.name = name;
}
}
var Ala = new Human("Ala");
console.log (Ala.inlineAttribute);

How to make link of method parameter type in jsDoc

Is there any natural way or special tag to make parameter type as link?
/**
* My js app
* #module app
*/
/**
* Namespace for MYAPP classes and functions.
* #namespace HUMAN_RESOURCE
*/
var HUMAN_RESOURCE = HUMAN_RESOURCE || {};
/**
* #class JustClass
* #constructor
*/
HUMAN_RESOURCE.JustClass = function(){ }
/**
* Constructs Person objects
* #class Person
* #constructor
* #param {String} First name
* #param {String} Last name
*/
HUMAN_RESOURCE.Person = function (first, last) {
/**
* First name of the Person
* #property first_name
* #type String
*/
this.first_name = first;
/**
* #property f_createPerson
* #param {Person} [_person] açıklama
* #return {Person} Person type object
*/
this.f_createPerson = function(_person, _person2){ return new Person() }
};
/**
* Return Person's full name
* #alias getName
* #memberof! HUMAN_RESOURCE.Person#
* #return {String} First name + last name
*/
HUMAN_RESOURCE.Person.prototype.getName = function () {
return this.first_name + ' ' + this.last_name;
};
Fortunately yes, it is just not always obvious what the correct name path is (but you can basically see it at the top of your generated docs)
/**
* #property f_createPerson
* #param {module:app~HUMAN_RESOURCE.Person} [_person] açıklama
* #return {module:app~HUMAN_RESOURCE.Person} Person type object
*/
this.f_createPerson = function(_person, _person2){ return new Person() }

Get empty collection of embedded documents

I want to get a collection of embedded documents. I put data into the database like this:
$dm->getRepository('BundleUserBundle:User')->addRatedPostById($user->getId(), new RatedPost($id, $type));
...which works fine. Now I see new data in mongo console, but when I'm trying to get this data via the getRatedPosts() method, it return null instead of the ArrayCollection. Whats wrong?
Context looks like this:
class User extends BaseUser {
/**
* #MongoDB\EmbedMany(targetDocument="RatedPost")
*/
protected $ratedPosts;
/**
* Add ratedPosts
*
* #param Bundle\UserBundle\Document\RatedPost $ratedPosts
*/
public function addRatedPost(\Bundle\UserBundle\Document\RatedPost $ratedPosts)
{
$this->ratedPosts[] = $ratedPosts;
}
/**
* Remove ratedPosts
*
* #param Bundle\UserBundle\Document\RatedPost $ratedPosts
*/
public function removeRatedPost(\Bundle\UserBundle\Document\RatedPost $ratedPosts)
{
$this->ratedPosts->removeElement($ratedPosts);
}
/**
* Get ratedPosts
*
* #return Doctrine\Common\Collections\Collection $ratedPosts
*/
public function getRatedPosts()
{
return $this->ratedPosts;
}
/**
* #MongoDB\EmbeddedDocument
*/
class RatedPost
{
/**
* #MongoDB\Int
*/
public $post;
/**
* #MongoDB\String
*/
public $rate;
...
}
I had exactly the same problems: saving was no problem but fetching the embedded document was. Turned out it was a "Symfony" caching problem (also on app_dev.php). Have you tried to remove your cache, this worked for me!