Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static-hostable support, by allowing changing the baseUrl at runtime #24

Conversation

dobromir-hristov
Copy link
Contributor

@dobromir-hristov dobromir-hristov commented Nov 18, 2021

Bug #: 70509237

Summary

Allow for the baseURL configuration, to be configurable at build-time, as well as runtime. This allows for the app, to be served from static file hostings that do not support URL rewrites, like Github Pages.

This PR utilizes already existing configurations from Vue CLI and Webpack.

Applied changes

  1. All json based asset paths are now prefixed with a baseUrl, which defaults to root (/).
  2. process.env.BASE_URL is a standard way to set the base url for Webpack and Vue CLI, so we use it to prefix our url.
  3. Adds a runtime configuration variable var baseUrl, allowing docc to inject a base url at runtime.
  4. Generates a new index-template.html file, for usage inside docc

Dependencies

swiftlang/swift-docc#44

Testing with the convert command

Steps:

  1. Build the app as normal npm run build
  2. Run DOCC_HTML_DIR=/path/to/dist docc convert ./path/to/MyFramework.docc --static-hosting-base-path /myname/myrepo/ --transform-for-static-hosting
  3. Move the output inside a /myname/myrepo/ folder.
  4. The final result can now be served with a server of your choice. If you visit http://localhost:[port]/myname/myrepo/documentation/my-framework, it should render your docs.

Testing with the process-archive command

  1. Build the app as normal npm run build
  2. Run DOCC_HTML_DIR=/path/to/dist docc process-archive transform-for-static-hosting ./path/to/MyFramework.doccarchive --static-hosting-base-path /myname/myrepo/
  3. Move the output inside a /myname/myrepo/ folder.
  4. The final result can now be served with a server of your choice. If you visit http://localhost:[port]/myname/myrepo/documentation/my-framework, it should render your docs.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Add tests
  • Add a release note in the radar
  • Assign the bug to the primary reviewer

@mportiz08
Copy link
Contributor

@swift-ci test

Copy link
Contributor

@mportiz08 mportiz08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Dobri! These changes will help anyone wanting to deploy generated docs to a non-root path of an existing website and be immediately impactful for GitHub Pages support.

@deekshithbellare
Copy link

Thank you for the great work. looking forward to see this merged, so that I can host the documentation on Github pages or S3

@mportiz08
Copy link
Contributor

@swift-ci test

@mportiz08 mportiz08 merged commit c15a633 into swiftlang:main Dec 9, 2021
@dobromir-hristov dobromir-hristov deleted the dhristov/r70509237-static-hostable-support branch December 10, 2021 08:22
mportiz08 pushed a commit to mportiz08/swift-docc-render that referenced this pull request Dec 10, 2021
mportiz08 added a commit that referenced this pull request Dec 15, 2021
…t runtime (#24) (#32)

Co-authored-by: Dobromir Hristov <dhristov@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants