Browse files

Added partial documentation to DTHTMLElement.

  • Loading branch information...
1 parent a49426e commit 3faa14f52b4f80876cacb6c09ac3faed55d2a4cc @joepasq committed Mar 5, 2012
Showing with 42 additions and 0 deletions.
  1. +42 −0 Core/Source/DTHTMLElement.h
@@ -34,9 +34,11 @@ typedef enum
} DTHTMLElementFontVariant;
+/** DTHTMLElement represents a single HTML element with CSS styles, that can have parents and children. */
@interface DTHTMLElement : NSObject <NSCopying>
@property (nonatomic, strong) DTHTMLElement *parent;
+// Document font descriptor first. */
@property (nonatomic, copy) DTCoreTextFontDescriptor *fontDescriptor;
@property (nonatomic, copy) DTCoreTextParagraphStyle *paragraphStyle;
@property (nonatomic, strong) DTTextAttachment *textAttachment;
@@ -58,26 +60,66 @@ typedef enum
@property (nonatomic, assign) DTHTMLElementFontVariant fontVariant;
@property (nonatomic, assign) CGFloat textScale;
@property (nonatomic, assign) CGSize size;
+/** Contains all attributes from parsing */
@property (nonatomic, strong) NSDictionary *attributes;
+/** @name Attributed string relevant methods. */
+/** Return an attributed string from the dictionary of attributes (attributesDictionary) applied to this element's text. If this element has a text attachment then the element's text is ignored in the attributed string being replaced by the unicode replacement character: �.
+ @returns An NSAttributedString of the attributes applied to this element and applied on this element's text if without a text attachment. */
- (NSAttributedString *)attributedString;
+/** */
- (NSAttributedString *)prefixForListItemWithCounter:(NSUInteger)listCounter;
+ @returns A dictionary of the attributes applied to this element. */
- (NSDictionary *)attributesDictionary;
+/** @name Styles methods */
+/** Parse a string for CSS styles and apply those styles to this element.
+ @param styleString A string containing CSS styles which are parsed and then applied to this element. */
- (void)parseStyleString:(NSString *)styleString;
+/** Applies the styles contained in styles parameter to this element.
+ @param styles Dictionary of CSS styles to be applied to this element. */
- (void)applyStyleDictionary:(NSDictionary *)styles;
+/** The styles applied to this element through parseStyleString: and applyStyleDictionary:. Stored as a CSS style dictionary.
+ @returns A dictionary of CSS styles that were applied to this element. */
- (NSDictionary *)styles;
+/** Add another attribute to the additional attributes dictionary which will be taken into account when generating the attributesDictionary.
+ @param attribute The attribute to add.
+ @param key The key for the added attribute.
+ */
- (void)addAdditionalAttribute:(id)attribute forKey:(id)key;
- (NSString *)path;
- (NSString *)attributeForKey:(NSString *)key;
+/** @name HTML child element methods */
+/** Adds a child element to this element's list of children.
+ @param child An HTML element to be added to this element's children. */
- (void)addChild:(DTHTMLElement *)child;
+/** Removes a specific child element.
+ @param child The child element instance to be removed as a child. */
- (void)removeChild:(DTHTMLElement *)child;
+/** Checks if this element's parent has the same tag name as the parameter name. Ascends the parent hierarchy to find the tag name.
+ If this parent doesn't have it, check the grandparents and so on). If no parent in the hierarchy has the correct tag the father elements's call to parentWithTagName: will return nil because it has no parent itself.
+ @param name The NSString tag name to check.
+ @returns The HTML element with the tag name */
- (DTHTMLElement *)parentWithTagName:(NSString *)name;
+/** Quick method to check if all parents display inline as used by block elements.
+ @returns YES if this method is within a block element. */
- (BOOL)isContainedInBlockElement;

0 comments on commit 3faa14f

Please sign in to comment.