- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
感谢在这里找到的答案:
https://stackoverflow.com/a/19336366/592495
我的 JavaScript 文档组织良好且格式正确。每个 namespace 都是其中包含的方法的“父级”。但是,导航并不像我希望的那样精细。
在通过一个简单的命令(jsdoc file1.js file2.js
)使用 node.js 工具编译/渲染后,文档将生成到默认模板中。此默认模板在侧边栏导航中显示我的命名空间,但它不显示每个包含的方法。
您可以通过向每个方法添加 @class
指令来伪造一个方法列表,但正如我们所知,它们并不是真正的类。
我希望看到这样的侧边栏导航:
My Project
- namespace 1
- method.a
- method.b
- method.c
-namespace 2
- method.d
- method.e
任何我忽略的文档指导都将不胜感激。
[编辑添加:]
经过实验,@class
几乎完全符合我的要求,但有一些异常(exception):
它列出了命名空间之上的类。我不喜欢这样,因为 namespace 实际上是“ parent ”。
JavaScript 没有那种意义上的类。不是那些被称为“类”的术语。当阅读文档以查看“类”列表时,它会产生奇怪的断开连接。
它会自动添加“new”运算符。并非所有方法都有构造函数……您可以看出问题所在!
[编辑:示例代码]
这是当前的结构。在我用 JSDoc 注释对其进行注释之前,这里是基本方法:
var app = app || {};
app.utils = {
whizbang: function() {},
geegolly: function() {}
};
app.render = {
thestuff: function(params) {},
thethings: function(params) {}
}
}
因此,使用对象字面量表示法,顶层是整个应用程序的“命名空间”,但其中有用于不同目的的子命名空间。在这里,我有一个特定于实用程序的子命名空间,以及另一个特定于渲染的子命名空间。每个都可以有属性,但更重要的是它们每个都包含功能。这些功能应该出现在侧边栏中。现在用我当前的 JSDoc 模式充实它:
/**
* @file MyApp.js This is an awesome description of MyApp.js
*
* @version 0.1
* @author Greg Pettit
* @copyright 2015
*
*/
/**
* Description of my main namespace!
*
* @namespace app
*/
var app = app || {};
/**
* This is a description of my sweet utilities namespace!
*
* @memberof app
* @type {object}
* @namespace app.utils
*/
app.utils = {
/**
* app.utils.whizbang is an awesome function with magical powers. I sure wish
* it would appear in the sidebar as a member of app.utils!
*
* @memberof app.utils
* @method whizbang
*
* @param {method} [successCallback] Method invoked on successful attempt.
* @param {method} [errorCallback] Method invoked on unsuccessful attempt.
*
*/
whizbang: function(successCallback, errorCallback) { // do utility stuff! }
}
/**
* This is a description of the best rendering namespace ever.
*
* @memberof app
* @type {object}
* @namespace app.render
*/
app.render = {
/**
* app.render.thethings renders the things! I wish it would render to the sidebar...
*
* @memberof app.render
* @method thethings
*
* @param {method} node The node to which thethings are rendered
*
*/
thethings: function(node) { // do rendering stuff! }
}
最佳答案
您是否尝试过使用 @lends
标签?您的代码示例和文档注释在这里会很有帮助。
由于我不知道您的代码是什么样的,所以我将举例说明我如何将 JSDoc 与我们的内部框架一起使用,该框架有很多特殊之处(嘿,我没有写,我只需要使用它)。
只是为了提供一些上下文,我们有一个可以创建应用程序和模块的 context
对象(应用程序只是具有 start
方法的模块):
/** @namespace MyApp */
var MyApp = context.app('myApp').use('module1', 'module2', 'underscore');
我们有一个用于主干的依赖注入(inject)系统,它使用 Angular 样式模式来表达依赖关系:
/**
* The constructor for MyModel
* @memberof MyApp
* @param {object?} attrs
* @param {object?} options
* @param {AppUtils} appUtils
* @constructor
*/
MyApp.MyModel = function(attrs, options, appUtils) {
this.options = options;
this.utils = appUtils;
}
// This is injected by the dependency resolver at instantiation time
// No additional JSDoc comments are necessary, it actually gets this right
MyApp.MyModel.prototype = {
idAttribute: 'customId',
defaults: {
customId: '',
name: '',
birthday: null
}
};
// Registers MyModel with the IOC container as 'myModelName'
MyApp.model('myModelName', [
'attrs',
'options',
'appUtils'
MyApp.MyModel
]);
然后一个不同的文件可以通过将它添加到底部的依赖数组来注入(inject)一个 myModelName 的实例。
有趣的是,JSDoc 实际上在理解特定安排方面做得很好,只要我不想太花哨......但以下模式显然对它来说太困惑了:
/**
* @memberof MyApp
* @param {MyApp.MyModel} myModel
* @param {urlParser} urlParser
* @constructor
*/
MyApp.SomeService = function(myModel, urlParser) {
return {
foo: function() {
//whatever
},
bar: function() {
//whatever
}
};
};
MyApp.service('someModuleName', [
'myModelName',
'urlParser',
MyApp.SomeService
]);
我发现唯一能给我任何接近所需输出的东西是使用@lends 标记告诉 JSDoc 特定对象/属性/方法作为不同的属性“借出”。例如,要记录 Backbone 模型的 attributes
属性(表面上由其 defaults
属性定义),我们这样做:
MyApp.MyModel.prototype = {
idAttribute: 'customId',
/** @lends MyApp.MyModel.prototype.attributes */
defaults: {
customId: '',
name: '',
birthday: null
}
};
对于服务返回对象的情况,我们发现记录这些对象属性的唯一方法是这样的:
/**
* @memberof MyApp
* @param {MyApp.MyModel} myModel
* @param {urlParser} urlParser
* @constructor
*/
MyApp.SomeService = function(myModel, urlParser) {
/** @lends MyApp.SomeService.prototype */
return {
foo: function() {
//whatever
},
bar: function() {
//whatever
}
};
};
我不知道这些是否有用,但也许它会给你一些想法,让你可以尝试使用 @lends
。如果您能提供一些示例代码,我可能会给您更有用的答案。
关于javascript - JSDoc 侧边栏中的嵌套方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30717084/
我想创建一个类似 ABOVE 的可折叠侧边栏。 在折叠的表单中,侧边栏将只有选项图标,当您将鼠标悬停在栏上时,它会展开,向您显示图标的描述/名称。 如果您单击该图标,它将带您进入该图标指定的功能,例如
由于我需要在右侧打开侧边栏,如何将其从左侧更改为右侧?我使用的代码很简单: if revealViewController() != nil { Menubutton.target
我在使用高度标签时遇到了问题。 我想制作一个背景延伸到页面底部的侧边栏。 我已将高度设置为 100%,但这并不像我想象的那样有效。 这是我的侧边栏代码。 #side{ box-sizing:b
我正在为我的网站构建一个过滤器侧边栏,我希望能够通过按 btn 打开和关闭过滤器列表。 jQuery('.parent > .children').parent().click(function()
我将如何使 CONTENT HERE 文本进入红色框区域。我几乎尝试了所有我能想到的方法,但没有任何效果。我什至尝试将文本排成一行,然后将其类设置为“行向左拉”。这是我的代码:
当然 Wordpress 2.7 里有“小工具”选项也能控制 Widget ,但是反复实验后发现样式无法统一,可控性较低。个人认为是比较鸡肋的功能,这里就不谈了。 进入正题。侧边栏
我正在为使用 Qt 和 QML for Ubuntu Linux 的应用程序构建 UI。我有一个带有 Canvas 元素的查看器窗口,默认情况下应该是全屏的。打开应用程序时效果很好(即隐藏了 Ubun
我有一个两列布局。左侧是正文,右侧是侧边栏 ( float: right; width: 30% )。 在小型浏览器上,我想先显示正文,然后是侧边栏。但是如果我删除 float从带有媒体查询的侧边栏中
我是 React 的新手,试图让这个组件工作:https://github.com/balloob/react-sidebar 它有效,除了在跟随链接时侧边栏不会关闭。如何单击侧边栏链接关闭侧边栏?
我开始使用 Sublime Text 2。但是有一个小问题,找不到将侧栏(文件夹平移)移动到窗口右侧的选项。 你能告诉我我该怎么做吗?是否有任何插件或设置选项。 最佳答案 遗憾的是,不支持此功能。 看
在下面的玩具示例中,我在侧边栏中有很多 slider 。对于最后一个,我再也看不到正确的情节了。这个问题有什么不涉及删除 slider 的解决方案吗? # 01-kmeans-app palette(
我想向 Finder 侧边栏添加一个新项目。我发现 Finder 将“地点”列表保存在 `~/Library/Preferences/com.apple.sidebarlists.plist 中。我能
我正在寻找创建一个固定侧边栏,与苹果的(就功能而言)非常相似。当您在他们的商店中配置您的 Mac 时,当您向下滚动页面时,右侧的购物篮会固定位置; 完美。 position:fixed 是相对于视口(
我想使用 SwiftUI 构建一个非常简单的 iOS 14 侧边栏。 设置很简单,我有三个 View HomeView , LibraryView和 SettingsView和一个代表每个屏幕的枚举。
Semantic-UI 预先警告其 sidebar page “当侧边栏出现时,固定位置内容可能无法更改其位置。”然后它提供了两种可能的解决方案。 令人惊讶的是,在同一个页面和整个网站上,Semant
有人用过 React Pro 侧边栏吗?有人可以告诉我如何使用 sass 侧边栏组件以及如何增加侧边栏的长度。是否还有其他库提供了如何使用其侧边栏的示例。这是 React Pro 侧边栏示例。
有人用过 React Pro 侧边栏吗?有人可以告诉我如何使用 sass 侧边栏组件以及如何增加侧边栏的长度。是否还有其他库提供了如何使用其侧边栏的示例。这是 React Pro 侧边栏示例。
我是 React 的新手,一直在尝试寻找一个示例,说明如何在 reactjs 中创建侧边导航栏并将 reactrouter 与它一起使用。现在,我有一个如下所示的“侧边导航” Pane : impor
我正在尝试制作一个像 semantic-ui.com 上那样的简单侧边栏,只是我希望它位于右侧。看起来很简单,除了让按钮附加是我最大的问题。你可以在 jsfiddle 看到它,有点工作......HT
我附上了我的 HTML 和 CSS,希望有人能帮助我。基本上我有一个右侧边栏 div,其中的内容不会推到顶部。当我尝试使用位置和高度属性时,内容只是漂浮在整个页面上,甚至不会停留在右侧边栏中。我希望有
我是一名优秀的程序员,十分优秀!