swiftlang / swift-docc-render

Web renderer for Swift-DocC documentation.
Apache License 2.0
315 stars 53 forks source link

Create a mixin for the index data getting logic #895

Closed hqhhuang closed 2 months ago

hqhhuang commented 2 months ago

Bug/issue #, if applicable: rdar://136089361

Summary

This is the 2nd PR of the refactor effort.

This PR does 2 small things:

  1. Create a mixin for the index data getting logic, to allow us to avoid repeating the logic that selects the correct language variant of the index data.
  2. set default state of flatChildren to null, so we don't need to create an additional variable to store isFetching. Instead, this can be computed by checking whether flatChildren is null and errorFetching is false.

Dependencies

NA

Testing

Steps:

  1. Check that there are no regressions

Checklist

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