Update docs to show new API.

Summary: Need API needs some new docs. I also removed the repo's `.hgignore` and added everything to fbobjc `.hgignore` via `./Tools/generate_hgignore.py` which uses Yoga's `.gitignore`.

Reviewed By: emilsjolander

Differential Revision: D4403967

fbshipit-source-id: f2158e4feb27953d1d9e21c775926e6207220c4a
This commit is contained in:
Dustin Shahidehpour
2017-01-12 10:16:12 -08:00
committed by Facebook Github Bot
parent c4a3e12add
commit adb81e2a1e
6 changed files with 33 additions and 98 deletions

4
.gitignore vendored
View File

@@ -7,6 +7,10 @@
/gentest/test.html
.buckversion
# Jekyll
/.sass-cache/
/_site/
# Visual studio code
.vscode
*.pdb

View File

@@ -1,58 +0,0 @@
.DS_STORE
/buck-cache/
/buck-out/
/.buckconfig.local
/.buckd
/gentest/test.html
.buckversion
# Visual studio code
.vscode
*.pdb
*.tlog
*.obj
*.pch
*.log
*.orig
# Xcode
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build

View File

@@ -19,7 +19,7 @@
- title: API
items:
- id: c
- id: objc
- id: yogakit
- id: java
- id: csharp
- id: javascript

View File

@@ -1,38 +0,0 @@
---
docid: objc
title: Objective-C
layout: docs
permalink: /docs/api/objc/
---
> The Objective-C API is very new and still in rapid development. Please use it and [report issues, bugs or feedback](https://github.com/facebook/yoga/issues). We hope to stabilize the API over the next couple weeks / months.
Yoga for Objective-C is implemented as a [category](https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Category.html) on [UIView](https://developer.apple.com/reference/uikit/uiview). We try to rely on the existing `UIView` properties and initializers where possible, making the Yoga API smaller for Objective-C than for other languages.
### Lifecycle
As with any `UIView` instantiate it using `-(instancetype)initWithFrame:(CGRect)frame`. With Yoga for Objective-C the frame is actually how you set the width and the height of the Yoga node, just like any other `UIView`.
Because Yoga is implemented as a category we need some way to mark the view as using Yoga as you might not want Yoga to control layout of your whole app, this is especially important if you are migrating an existing app to use Yoga. The property decides during layout/sizing whether or not `yg_*` properties should be applied. Defaults to `NO`.
<script src="https://gist.github.com/emilsjolander/b95467f51b945e906d39b66e44999806.js"></script>
### Children
Yoga relies on `UIView` subviews to build up its internal layout tree. However using properties such as `yg_includeInLayout` a View can exclude itself from layout. Therefor we provide the following method to query the number of children which are laid out using Yoga.
<script src="https://gist.github.com/emilsjolander/253d69b12bef2ee1ec899ace81b768a6.js"></script>
### Style setters
The large part of Yoga's API consists of setters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/e7c7732b9465173335d2e019a6bc5941.js"></script>
### Layout
- `yg_includeInLayout` decides if we should include this view when calculating layout. Defaults to `YES`.
- `yg_intrinsicSize` returns the size of the view if no constraints were given. This is equivalent to calling `[view sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]`.
- `yg_applyLayout` performs layout calculation and update the frames of the views in the hierarchy with the results.
- `yg_resolvedDirection` returns the resolved layout direction of this view. Either `YGDirectionRTL` or `YGDirectionLTR`.
<script src="https://gist.github.com/emilsjolander/437661e872c1f9106b728419d5ea49e9.js"></script>

27
docs/_docs/api/yogakit.md Normal file
View File

@@ -0,0 +1,27 @@
---
docid: yogakit
title: YogaKit
layout: docs
permalink: /docs/api/yogakit/
---
> The YogaKit API is still in rapid development. Please use it and [report issues, bugs or feedback](https://github.com/facebook/yoga/issues).
YogaKit is a Objective-C (and Swift-compatible) wrapper for Yoga. It allows iOS Developers to manage the layout of their views using the power of Yoga.
Layout configuration is done via the [YGLayout](https://github.com/facebook/yoga/blob/master/YogaKit/YGLayout.h) object. YogaKit exposes `YGLayout` via a [category](https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Category.html) on [UIView](https://developer.apple.com/reference/uikit/uiview).
### Lifecycle
As with any `UIView`, instantiate it using `-(instancetype)initWithFrame:(CGRect)frame`. YogaKit uses the frame of the parent view to determine the space that is available for children in layout.
### Children
Yoga relies on `UIView` subviews to build up its internal layout tree. However, a subview can exclude itself from layout by setting the `isIncludedInLayout` property on `YGLayout` to `NO`.
It is also possible to query the number of children **included** in layout via `numberOfChildren`.
### Layout
To apply a layout to a view (and its' subviews) you need to call `[view.yoga applyLayout]`. This will do a layout calculation (if needed) and apply the calculated frames to every view included in the layout.
In the event that you need to another layout pass on a view you can mark it dirty via `[view.yoga markDirty]`.

View File

@@ -29,7 +29,7 @@ id: home
</div>
</div>
<div class="blockContent gistsample">
<script src="https://gist.github.com/emilsjolander/56c2ea1167dafdc996a2527aa4c8ec7c.js"></script>
<script src="https://gist.github.com/dshahidehpour/a426c443a1e02c5432b22b09c457ede0.js"></script>
</div>
</div>
</div>