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

Implemented small change to markdown formatting, and added docs #34

Closed
wants to merge 3 commits into from

Conversation

auddithio
Copy link

@auddithio auddithio commented Mar 5, 2024

Markdown formatting + documentation

♻️ Current situation & Problem

The current SpeziViews module were not all well documented equally, as per the documentation requirements set forth in the Stanford Spezi Documentation Guide.. Also, the markdown formatting was restricted to inlineOnly changes, which would not render formatting for larger changes like titles, which was the issue our app's consent doc ran into.

⚙️ Release Notes

  • Changed markdown formatting to .full to incorporate the full breadth of document markdowns
  • Added documentation for the Localizable strings section in text

📚 Documentation

✅ Testing

  • For the markdown formatting, used the AttributedString framework to render markdown documents locally, and it seemed to render properly. Not sure what edge cases the Spezi team wanted to account for by setting it to inline, so further testing for the full template application is needed.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

One of our markdown consent documents were not rendering properly, hence this. Not sure why Spezi team restricted to inline only - open to feedback!
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.72%. Comparing base (4d2a724) to head (985eb86).

❗ Current head 985eb86 differs from pull request most recent head 4cf7645. Consider uploading reports for the commit 4cf7645 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   79.72%   79.72%           
=======================================
  Files          41       41           
  Lines        1242     1242           
=======================================
  Hits          990      990           
  Misses        252      252           
Files Coverage Δ
Sources/SpeziViews/Views/Text/MarkdownView.swift 69.82% <100.00%> (ø)
Sources/SpeziViews/Views/Text/TextContent.swift 100.00% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d2a724...4cf7645. Read the comment docs.

Copy link
Member

@Supereg Supereg left a comment

Choose a reason for hiding this comment

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

Thank you for improving the documentation of SpeziViews. Thanks for the PR.

I only had small comment regarding a code example on one of the documentation blocks. Otherwise, the PR looks good 👍

Comment on lines 99 to 101
/// Example: Data(
/// " # This is a markdown example
/// *This should be italiced* and **this bolded**").utf8
Copy link
Member

Choose a reason for hiding this comment

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

If this is a code example, make sure to wrap them into markdown swift code block, as you did for the `TextContent´ type as well.
This makes sure that inline code appears with proper syntax highlighting. Make sure to properly format the code according to your swiftlint code style rules.

@auddithio auddithio requested a review from Supereg March 15, 2024 00:54
@auddithio
Copy link
Author

made some changes based on feedback and after talking to Spezi staff!

Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

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

@auddithio Thank you for the PR; I had a few further comments and suggestions that would need to be addressed before we merge the PR 👍

@@ -66,6 +66,7 @@ public struct MarkdownView: View {


/// Creates a ``MarkdownView`` that displays the content of a markdown file as an utf8 representation that is loaded asynchronously.

Copy link
Member

Choose a reason for hiding this comment

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

Please remove the empty line added here, it breaks the documentation block:

Suggested change

Comment on lines +99 to +103
/// ```swift
/// // Example
/// Data(" # This is a markdown example
/// *This should be italiced* and **this bolded**").utf8
/// ```
Copy link
Member

Choose a reason for hiding this comment

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

This code example does not compile, if you want to create a String with line breaks you will have to use a multi-line string interval: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/stringsandcharacters/#Multiline-String-Literals

In addition, the code example does not call the API.

Comments like //Example should be removed and I would suggest to rather add an explanation around the example block.

Last but not least, I would move the example above the parameters section of the code documentation.

/// - Returns: Parsed Markdown as an `AttributedString`
@MainActor private func parse(markdown: Data) -> AttributedString {
state = .processing

guard let markdownString = try? AttributedString(
markdown: markdown,
options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
options: .init(interpretedSyntax: .inlineOnly)
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for this change? Wouldn't it make sense to switch to .full?

Comment on lines +15 to +20
/// ```swift
/// // Example usage:
/// let content: TextContent = .localized(LocalizedStringResource("HELLO_SPEZI", bundle: .main))
/// let localizedString = content.localizedString(for: .current)
/// print(localizedString) // Prints the localized string for the current locale.
/// ```
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the added documentation!

The same comments about the example also apply here as well.

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.

None yet

3 participants