docs: function buildJSONSource() {
  
    var data = getModularSource();
  
    addCorePackage();
    prepareData();
    outputJSON('source.json', data);
  
    function addCorePackage() {
      data.modules.unshift({
        name: 'Core'
      });
      data.packages.unshift({
        name: 'Sugar',
        type: 'core',
        module: 'Core',
        dependencies: [],
        bodyWithComments: readFile('lib/core.js').trim()
      });
    }
  
    function bundleSetPackages() {
      var packages = [], handledSets = {}, p;
  
      for (var i = 0; i < data.packages.length; i++) {
        p = data.packages[i];
        if (p.set) {
          // If the package has been handled already then just skip.
          if (!handledSets[p.namespace + p.setName]) {
            packages.push({
              setName: p.setName,
              name: p.setName.replace(/[\[\]]/g, ''),
              sample: p.set.slice(0, 3).concat('...').join(', '),
              type: p.type,
              alias: p.alias,
              module: p.module,
              namespace: p.namespace,
              dependencies: p.dependencies,
              bodyWithComments: p.bodyWithComments
            });
            handledSets[p.namespace + p.setName] = true;
          }
        } else {
          packages.push(p);
        }
      }
  
      return packages;
    }
  
    function prepareData() {
      var bundledPackages = bundleSetPackages();
      data.modules.forEach(function(m) {
        indentField(m, 'comment');
      });
      bundledPackages.forEach(function(p) {
  
        // Pre-indenting all packages rather than doing it on compile to
        // save some cycles and also correctly calculate the package size.
        indentField(p, 'blockStart');
        indentField(p, 'blockEnd');
        indentField(p, 'bodyWithComments');
  
        cleanSourcePackage(p);
      });
      data.packages = bundledPackages;
    }
  
    function indentField(p, field) {
      if (p[field]) {
        p[field] = p[field].replace(/^(?=.)/gm, '  ');
      }
    }
  
    function cleanSourcePackage(p) {
      if (sourcePackageIsDependency(p)) {
        delete p.type;
      }
      delete p.vars;
      delete p.target;
      delete p.body;
      delete p.path;
      delete p.assigns;
      delete p.comments;
      delete p.defineMethod;
      delete p.varDependencies;
      compactField(p, 'bodyWithComments');
      compactField(p, 'dependencies');
    }
  
    function compactField(p, field) {
      var val = p[field];
      if (!val || (Array.isArray(val) && !val.length)) {
        delete p[field];
      }
    }
  
  }