Skip to content

Commit

Permalink
[Feature] Create default Styler for attributed string rendering (#177)
Browse files Browse the repository at this point in the history
* Add stubs

* Add some helper methods

* Add very basic styling

* Add custom dynamic type for code

* Clean up

* Allow DebugVisitor methods to be overridden

* Add method to calculate list depth

* Pass the list nest depth to the styler

* Move nest depth property to base node

* Add helper to get parent

* Add property to check for top level paragraphs

* Add test

* Pass top level flag to paragraph styler

* Only add pargraph style for top level paragraphs

* Create ListItemPrefixGenerator

* Use list item prefix generator

* Fix debug description

* WIP: list item styling

* Add tests

* Tidy up

* Use paragraph separator code point

* Add list markers

* Add todo

* Add tests

* Tidy up

* Calculate ranges of paragraphs excluding lists

* Add item styling stubs

* Format indentation of nested liists

* Refactor item styling

* Return self if prefix length exceeds bounds

* Add spacing after heading

* Tidy up

* Add todo

* Organize tests

* Rename method

* Add test stubs

* Add tests

* Reorganize files

* Add tests

* Loosen coupling between List and ListItemPrefixGenerator

* Add snapshot testing framework

* Bump minimum deployment to iOS 10 for test target

* Refactor FontBook into FontCollection

* Inject fonts into DefaultStyler

* Create ParagraphStyleCollection & inject into DefaultStyler

* Tidy up

* Create ColorCollection & inject into Default Styler

* Style block quote

* Style code blocks

* Add colors to headings, text and inline code

* Move AttributeCollection into new file

* Organize file structure

* Rename item paragraph styler

* Style list item prefix in the styler

* Make ListItemParagraphStyler configurable

* Add base test suite for styler

* Tidy up

* Add test stubs for list items

* Fix prefix indentation

* Add item prefix tests

* Allow styler properties to be externally configured

* Refactor styler test suite

* Make ListItemParargraphStyler a class

* Clean up

* Add new item styling tests

* Ignore some test stubs

* Use snapshots for visitor tests

* Add snapshots for strong, emphasized, code and html styles

* Clean up

* Explicitly set point size after adding font trait

* Add monospace trait to font extension

* Allow monospace font in headings

* Use heading level when styling

* Make test properties private

* Add heading style tests

* Add todos

* Use line separators in code blocks

* Add code paragraph style

* Add support for custom thematic break attribute

* Add DownTextView

* Add thematic break to color collection

* Add test for thematic break style

* Append newline instead of line separator after thematic break

* Add support for custom quote stripe attribute

* Translate thematic break rect to container origin

* Translate stripe by container origin

* Clean up

* Remove insets property & use origin parameter

* Clean up

* Add quote stripe options

* Move list item options to new file

* Add quote styling tests

* Allow thematic break to be configured

* Test thematic break preservation in block quote

* Add todos

* Add some more extension methods

* Add support for rendering quotes in a list

* Incrementally indent list items

* Fix quote indentation in list item

* Rename methods

* Clean up

* Add test

* Fix line break after code blocks

* Add code block style tests

* Add assert helper

* Clean up tests

* Set text container inset before fitting size to content

* Extract DownDebugLayoutManager and DownDebugTextView

* Allow snapshots to show line fragments

* Add color to links

* Add link style tests

* Clean up file structure

* Remove redundant imports

* Clean up file structure

* Fix DownTextView init

* Draw line fragments in DownDebugLayoutManager

* Add debug style tests

* Clean up file structure

* Remove isTopLevel from Paragraph

* Remove nestDepth from list item

* Remove unused extension method

* Remove unused attribute keys

* Provide public init for ThematicBreakOptions

* Move max prefix width calculation to ListItemParagraphStyler

* Rename DefaultStyler to DownStyler

* Extract styles into a configuration struct

* Clean up

* Clean up

* Remove AttributeCollection

* Remove color from QuoteStripeOptions

* Clean up

* Remove defaults from custom attributes

* Render markdown within DownTextView

* Fix quote stripe rendering

* Revert "Fix quote stripe rendering"

This reverts commit 72f7783.

* Tidy up

* Enrich code blocks with background color

* Remove redundant initializers

* Add CodeBlockOptions

* Clean up

* Make extension local and private

* Remove some duplication

* Rename method

* Move non private extensions into new files

* Remove duplication

* Clean up

* Add tests

* Rename method

* Add tests

* Fix prefix  generation

* Add tests

* File organization

* Add tests

* Clean up

* Remove duplicate comment

* Flatten code & html block descriptions into single line

* Add tests

* Clean up

* Remove dynamic fonts

* Initial steps to support macOS & tvOS

* Rename font traits

* Further support for macOS

* Clean up

* Use iPhone Xs simulator when testings on Travis

* Clean up old todos

* Add Styler documentation

* Add documentation

* Make setter private

* Remove duplication

* Fix typo

* Name magic numbers

* Make FontCollection and ColorCollection protocols

* Return self instead of nil

* Mark feature unavailable for watchOS

* Update to snapshot testing 1.6

* Check in snapshot testing framework for iOS

* Re-record list item snapshots

* Remove old TODO

* Fix compiler error for macOS

* Compile snapshot tests for iOS only

* Specify Xcode 11 for CI

* Move snapshot tests into separate test target

* Revert "Compile snapshot tests for iOS only"

This reverts commit 95b2bf1.

* Run snapshot tests on CI

* Fix travis config

* Fix travis config again

* Fix missing file error

* Re-record snapshots on iPhone 11

* Update travis config

* slather DownShapshotTests

* Provide explicit types in styler configuration

* [Copyright] Update org name and years

* [CI] Try using Codecov for merged reports

* [Travis] Try doing Codecov after each slather

* [Xcode] Share DownSnapshotTests scheme w/ code coverage

* [CI] Use separate codecov report dirs

* [CI] Don't slather, just use codecov
  • Loading branch information
johnxnguyen authored Oct 6, 2019
1 parent 3f5dfe3 commit 02d90cc
Show file tree
Hide file tree
Showing 199 changed files with 4,770 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Carthage/Checkouts/
Pods/
.build/
.DS_Store
xcuserdata

# additional ignores that will save us time
build/
*.pbxuser
!default.pbxuser
*.mode1v3
Expand Down
5 changes: 0 additions & 5 deletions .slather.yml

This file was deleted.

14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
osx_image: xcode10.2
osx_image: xcode11
language: objective-c
before_install:
- set -o pipefail
- gem install xcpretty slather -N
- xcrun simctl boot "iPhone 7" || echo "(Pre)Launched the simulator."
- xcrun simctl boot "iPhone 11" || echo "(Pre)Launched the simulator."
script:
- travis_retry xcodebuild -project Down.xcodeproj -scheme "Down" -destination "platform=iOS Simulator,name=iPhone 7" -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test | xcpretty -c
- travis_retry xcodebuild -project Down.xcodeproj -scheme "Down" -sdk macosx -destination 'platform=OS X,arch=x86_64' -enableCodeCoverage YES test | xcpretty -c
- travis_retry xcodebuild -project Down.xcodeproj -scheme "Down" -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' -enableCodeCoverage YES test | xcpretty -c
- travis_retry xcodebuild -project Down.xcodeproj -scheme "Down" -sdk iphonesimulator -destination "platform=iOS Simulator,OS=13.0,name=iPhone 11" -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test
- travis_retry xcodebuild -project Down.xcodeproj -scheme "Down" -sdk macosx -destination 'platform=OS X,arch=x86_64' -enableCodeCoverage YES test
- travis_retry xcodebuild -project Down.xcodeproj -scheme "Down" -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' -enableCodeCoverage YES test
- travis_retry xcodebuild -project Down.xcodeproj -scheme "DownSnapshotTests" -sdk iphonesimulator -destination "platform=iOS Simulator,OS=13.0,name=iPhone 11" -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test
after_success:
- slather coverage --ignore "../**/*/Xcode*" --ignore "Source/cmark/*" --scheme "Down" Down.xcodeproj
- bash <(curl -s https://codecov.io/bash)
1 change: 1 addition & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "pointfreeco/swift-snapshot-testing" ~> 1.6
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "pointfreeco/swift-snapshot-testing" "1.6.0"
9 changes: 9 additions & 0 deletions Carthage/Build/.swift-snapshot-testing.version

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading

0 comments on commit 02d90cc

Please sign in to comment.