无法查看生成的文档
问题描述:
的描述
虽然我能够从文件系统服务grunt-ngdocs
自动生成index.html
,每次我尝试看看我得到的文档中描述:无法查看生成的文档
XMLHttpRequest cannot load file:///C:/<file-path> Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource
即使docs/partials
和docs/partials/api
文件夹都是空的。
这是我grunt-ngdocs
配置
ngdocs: {
options: {
dest: 'docs',
html5Mode: false,
inlinePartials: true,
scripts: [
'bower_components/angular/angular.js',
'bower_components/angular-animate/angular-animate.js'
]
},
api: {
src: ['app/scripts/**/*.js'],
title: 'Docs'
}
}
我在做什么错?
谢谢你提前
答
问题是你必须从服务器运行它。我使用节点http服务器(https://www.npmjs.com/package/http-server)。安装完毕后,进入docs /目录并键入'http-server'。您将获得以下信息:
启动了HTTP服务器,在服务./:http://0.0.0.0:8080
现在,您可以查看在给定的URL(http://0.0.0.0:8080)
编辑文档:
如果您不想从服务器加载它,可以在gruntfile中将选项inlinePartials设置为true。这是我有:
ngdocs: {
options: {
dest: 'docs',
title: "Docs",
inlinePartials: true
},
api: {
src: ['<%= yeoman.app %>/scripts/**/*.js'],
title: 'API Documentation'
}
},
谢谢您的回答,但事实是我试图避免解决方案,因为贡献者之一说[NG-文档可以送达通过文件系统](https://github.com/m7r/grunt-ngdocs/issues/148#issuecomment-110430549);此外,我发现在一个问题有点与我有关['grunt serve:dist'](http://stackoverflow.com/a/21285745/4277702):你能告诉我是否有可能使用ngdocs使用那个Grunt任务? – Gargaroz
我检查过是否有其他方法,ngdocs确实允许您将所有模板内联。这将避免XMLHttpRequest错误。检查编辑的答案。 – andreboekhorst
我的问题是我**在我的Gruntfile中有'inlinePartials:true',但我仍然收到XMLHttpRequest错误 – Gargaroz