function scanDocument(doc) {
        if (!_cachedValues.hasOwnProperty(doc.file.fullPath)) {
            doc.on("change.htmlInstrumentation", function () {
                if (_cachedValues[doc.file.fullPath]) {
                    _cachedValues[doc.file.fullPath].dirty = true;
                }
            });

            // Assign to cache, but don't set a value yet
            _cachedValues[doc.file.fullPath] = null;
        }

        var cachedValue = _cachedValues[doc.file.fullPath];
        if (!doc.isDirty && cachedValue && !cachedValue.dirty && cachedValue.timestamp === doc.diskTimestamp) {
            return cachedValue.dom;
        }

        var text = doc.getText(),
            dom = HTMLSimpleDOM.build(text);

        if (dom) {
            // Cache results
            _cachedValues[doc.file.fullPath] = {
                timestamp: doc.diskTimestamp,
                dom: dom,
                dirty: false
            };
        }

        return dom;
    }
Parses the document, returning an HTMLSimpleDOM structure and caching it as the
initial state of the document. Will return a cached copy of the DOM if the
document hasn't changed since the last time scanDocument was called.

This is called by generateInstrumentedHTML(), but it can be useful to call it
ahead of time so the DOM is cached and doesn't need to be rescanned when the
instrumented HTML is requested by the browser.

@param {Document} doc The doc to scan.
@return {Object} Root DOM node of the document.