Skip to content
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

shortname is not set correctly. #296

Open
Lusito opened this issue Dec 9, 2014 · 6 comments
Open

shortname is not set correctly. #296

Lusito opened this issue Dec 9, 2014 · 6 comments
Assignees
Labels

Comments

@Lusito
Copy link

Lusito commented Dec 9, 2014

When using AMD style classes, you normally access constructors without the full namespace.

require(["some/path/MyClass"], function (MyClass) {
    //...
    var obj = new MyClass();
    //...

So I wanted to create a modified theme, in which I wanted to display the short name of the constructor on the class detail page.
I found an attribute "shortname" in the data.json, but it matches name exactly, including the namespace.
I'm guessing this is a bug, since there are code snippets in docparser.js that concat namespace and shortname.

In docparser.js, I found this code:

block.forEach(function (def) {
    if (def.tag === 'namespace') {
        //We have a namespace, augment the name
        var name = trim(def.value) + '.' + value;
        if (value.indexOf(trim(def.value) + '.') === -1) {
            value = name;
            namespace = trim(def.value);
        }
    }
});

When commented out, it creates shortname correctly. Not sure if there are any negative side effects.

@okuryu
Copy link
Member

okuryu commented Dec 9, 2014

Could you provide your JavaScript comments for docs? IMO, it should be works regardless of JavaScript code styles.

@Lusito
Copy link
Author

Lusito commented Dec 9, 2014

/**
 * @class MyClass
 * @namespace some.path
 * @constructor
 */

@Lusito
Copy link
Author

Lusito commented Dec 9, 2014

It works correctly when I put the namespace in a separate comment block:

/**
 * @namespace some.path
 */
/**
 * @class MapController
 * @constructor
 */

@okuryu
Copy link
Member

okuryu commented Dec 10, 2014

Hmm, both works for me. Are you using the latest YUIDoc 0.4.0?
2014-12-10 at 9 50
2014-12-10 at 9 51

$ yuidoc .
info: (yuidoc): Starting YUIDoc@0.4.0 using YUI@3.18.1 with NodeJS@0.10.33
info: (yuidoc): Scanning for yuidoc.json file.
info: (yuidoc): Loading yuidoc.json data from: /Users/okuryu/work/test-yuidoc/yuidoc.json
info: (yuidoc): Starting YUIDoc with the following options:
info: (yuidoc):
{ outdir: './output',
  port: 3000,
  nocode: false,
  paths: [ '.' ],
  project:
   { name: 'YUIDoc Test',
     description: 'YUIDoc Test Project',
     version: '1.2.3',
     url: 'http://example.com/',
     logo: './logo.jpg' } }
info: (yuidoc): YUIDoc Starting from: .
warn: (yuidoc): Found out dir, deleting: ./output
info: (yuidoc): Making out dir: ./output
info: (yuidoc): Parsed 8 files in 0.013 seconds
info: (builder): Building..
info: (builder): Compiling Templates
info: (builder): Making default directories: classes,modules,files
info: (builder): Copying Assets
info: (builder): Rendering and writing 0 modules pages.
info: (builder): Finished writing module files
info: (builder): Rendering and writing 1 class pages.
info: (builder): Loading theme from /Users/okuryu/work/yuidoc/themes/default/theme.json
info: (builder): Preparing index.html
info: (builder): Writing API Meta Data
info: (builder): Finished writing class files
info: (builder): Rendering and writing 1 source files.
info: (builder): Writing index.html
info: (builder): Finished writing source files
info: (builder): Finished writing 3 files in 0.118 seconds
info: (yuidoc): Completed in 0.136 seconds

@Lusito
Copy link
Author

Lusito commented Dec 10, 2014

Yes I am using 0.4.0, but you don't seem to get my Problem.. I want the part below "Constructor" to only show the short name, i.e. "MapController". This should be possible using the json data, but the json data shows

        "name": "some.path.MapController",
        "shortname": "some.path.MapController",  

But it should show:

        "name": "some.path.MapController",
        "shortname": "MapController",  

@okuryu
Copy link
Member

okuryu commented Dec 10, 2014

Aha, gotcha. It seems to be a bug, but it has no effect on the default theme. I'll take a look later!

@okuryu okuryu added the bug label Dec 10, 2014
@okuryu okuryu self-assigned this Dec 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants