1
0

shorturls.py 569 B

12345678910111213141516171819202122
  1. '''
  2. Short-URL redirects
  3. '''
  4. import json
  5. import os
  6. import sphinx.ext.intersphinx
  7. DOCS_URL = 'http://docs.saltstack.com/en/latest/'
  8. def write_urls_index(app, exc):
  9. '''
  10. Generate a JSON file to serve as an index for short-URL lookups
  11. '''
  12. inventory = os.path.join(app.builder.outdir, 'objects.inv')
  13. objects = sphinx.ext.intersphinx.fetch_inventory(app, DOCS_URL, inventory)
  14. with open(os.path.join(app.builder.outdir, 'shorturls.json'), 'w') as f:
  15. json.dump(objects, f)
  16. def setup(app):
  17. app.connect('build-finished', write_urls_index)