无法查看生成的文档

问题描述:

的描述

虽然我能够从文件系统服务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/partialsdocs/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' 
    } 
}, 

见(https://github.com/m7r/grunt-ngdocs

+0

谢谢您的回答,但事实是我试图避免解决方案,因为贡献者之一说[NG-文档可以送达通过文件系统](https://github.com/m7r/grunt-ngdocs/issues/148#issuecomment-110430549);此外,我发现在一个问题有点与我有关['grunt serve:dist'](http://*.com/a/21285745/4277702):你能告诉我是否有可能使用ngdocs使用那个Grunt任务? – Gargaroz

+0

我检查过是否有其他方法,ngdocs确实允许您将所有模板内联。这将避免XMLHttpRequest错误。检查编辑的答案。 – andreboekhorst

+0

我的问题是我**在我的Gruntfile中有'inlinePartials:true',但我仍然收到XMLHttpRequest错误 – Gargaroz