How can I build YUIDoc with offline resources?

426 Views Asked by At

When you build & run YUIDoc it gets some of his resources from http://yui.yahooapis.com/.... These resources include the stylesheet and yui.min.js.
How can I download and use these resources offline?

The reason for this is because we run our docs on a HTTPS server. The YUIDoc serves his files always over HTTP protocol.

1

There are 1 best solutions below

3
On BEST ANSWER

I had the same problem and I really don’t understand why the don’t have a valid certificate for yui.yahooapis.com. Here’s what works for me (with YUIDoc 0.5.0):

Create a custom theme

First of all, you’ll need to create a new theme that overrides some parts of the default theme.

Create the following folder structure:

my_theme
├── assets
│   ├── css
│   └── yui
└── layouts

Modify the main layout

To avoid loading the remote CSS and scripts, you need to alter the main layout.

Copy the file called main.handlebars from the original theme to your my_theme/layouts/ folder. If you installed YUIDoc via node, the original file is located in node_modules/yuidocjs/themes/default/layouts/. Alternatively, you can grab it from the yuidoc GitHub repo.

Make the following changes in that file:

1.) Replace the link tag referencing the remote stylesheet:

<link rel="stylesheet" href="{{yuiGridsUrl}}">
<link rel="stylesheet" href="{{projectAssets}}/css/cssgrids-min.css">

2.) Replace the script tag referencing the remote YUI library:

<script src="{{yuiSeedUrl}}"></script>
<script src="{{projectAssets}}/yui/build/yui-base/yui-base-min.js"></script>

Add a local copy of the remote assets

1.) Fetch the CSS from Yahoo’s CDN

Download cssgrids-min.css from the Yahoo CDN and put it in your my_theme/assets/css folder.

2.) Download the YUI 3.9.1 library

Download YUI 3.9.1 from http://yui.zenfs.com/releases/yui3/yui_3.9.1.zip (Release Notes) and put the build folder from the archive to my_theme/assets/yui.

Build your docs

When building your docs, make sure you specify your custom theme:

$ yuidoc my_js_folder --themedir my_theme

Possible improvements

Since this adds a bunch of files to your project, it might make sense to dive a little deeper into YUIDoc and see which YUI modules are actually required and remove everything else. Also, combining the files would be desirable (the library served form Yahoo’s CDN does this and it should be possible to get this working locally as well).