简体   繁体   English

我如何浏览本地项目文档

[英]How can I browse local project documentation

Is there any Rails way to browse the documentation generated in local doc/ folder with the command rake doc:app ? 有什么Rails方法可以使用rake doc:app命令浏览在本地doc/文件夹中生成的doc/吗?

I know I could configure Apache to serve the files in the doc folder but I would be surprised if Rails didn't provide a way to do that too. 我知道我可以配置Apache以提供doc文件夹中的文件,但是如果Rails也没有提供这样做的方法,我会感到惊讶。

The reason Rails doesn't provide a way to serve it is because it's just static HTML - you can open it in your browser directly (eg. firefox doc/app/index.html ), without the need for a server. Rails无法提供服务的原因是因为它只是静态HTML-您可以直接在浏览器中打开它(例如firefox doc/app/index.html ),而无需服务器。

If you wanted, you could add your own Rake task for this in lib/tasks/browserdoc.rake : 如果需要,可以在lib/tasks/browserdoc.rake为此添加自己的Rake任务:

namespace :doc do
    desc "Browse application documentation"
    task :open do
        `firefox doc/app/index.html`
    end
end

Some systems have browser-agnostic shortcuts you could use instead of hard-coding the browser name; 某些系统具有与浏览器无关的快捷方式,您可以使用它们来代替硬编码浏览器名称。 open on Mac OSX will open an HTML file in your current browser, as will sensible-browser on most modern Linux systems. 在Mac OSX上open ,将在您当前的浏览器中打开HTML文件,就像大多数现代Linux系统上的sensible-browser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM