3

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.

A1rPun
  • 16,287
  • 7
  • 57
  • 90

1 Answers1

5

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).

aaronk6
  • 2,701
  • 1
  • 19
  • 28
  • Thanks @aaronk6, I tried something like this yesterday and the `yui.js` still did some HTTP ajax requests. I'm gonna try your solution now :) – A1rPun Jan 22 '15 at 10:19
  • Yes it worked perfectly :) Thanks for your exellent answer and concern. – A1rPun Jan 23 '15 at 10:04
  • 1
    This is also how you can get the documentation output working in an offline environment. I made an offline theme following these steps, including only using the minimum amount of yui modules - which by the way, was 69 modules and an assets folder in my case. Combining the files is possible by running a local bundling (combo) server, but I didn't go that far - running it from the file system loads fast enough for me. – J c Feb 19 '15 at 05:41