-
Notifications
You must be signed in to change notification settings - Fork 162
Add a public initializer to RenderContentMetadata #1337
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
base: main
Are you sure you want to change the base?
Add a public initializer to RenderContentMetadata #1337
Conversation
Sources/SwiftDocC/Model/Rendering/Content/RenderContentMetadata.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to have this test but I don't find it important to test that initializers set the properties of a structure because the compiler will already enforce that the initializer assigns a value to every property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this unit test some more, I've decided to rename & move the Swift file and test class to something more generic. I think this test file could be generally useful in the future for testing public access to various DocC API.
See: c587ac9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think running a test is a good mechanism for verifying that a piece of API is public. To my knowledge we don't do that for any other public API.
I personally don't think that having this test will meaningfully help us remember to make other future API in other types public and I think that the odds that this test protects us against unintentionally removing this API or changing it to a lower access level is abysmal.
I don't think it's harmful to have this test but I think the value it adds is fairly close to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify; I'm not requesting that we remove this test, but I feel that the discussion around adding it has already cost more time and productivity that we'll ever regain from having this test.
…a.swift Co-authored-by: David Rönnqvist <ronnqvist@apple.com>
Bug/issue #, if applicable: rdar://164210651
Summary
RenderContentMetadata, which is part of the Render JSON schema, doesn’t have a public initializer. This prevents other applications linking to Swift DocC from creating new metadata instances. This change adds a public initializer.Dependencies
None.
Testing
Write a small Swift CLI executable program that links to Swift DocC, and then test that you can create an instance of
RenderContentMetadatausing this new public initializer.Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeeded