#

API Docs for: 0.3.35
Show: Inherited Protected Private Deprecated

# Utils Class

Defined in: `lib/utils.js:11`
Module: yuidoc

Utilities Class

- Index
- Methods

## Item Index

### Methods

- escapeHTML
- fixType
- getDirs
- getLayouts
- getPage
- getPages
- getPartials
- getProjectData
- prepare
- unindent
- validatePaths

## Methods

### `escapeHTML`

(

- `html`

)
String

Defined in `lib/utils.js:31`

Escapes HTML characters in html.

#### Parameters:

- `html` String

  String to escape.

#### Returns:

String: Escaped string.

### `fixType`

(

- `t`

)
String

Defined in `lib/utils.js:407`

Takes a type string and converts it to a "First letter upper cased" type. e.g. `(string -> String, object -> Object)`

#### Parameters:

- `t` String

  The type string to convert

#### Returns:

String: The fixed string

### `getDirs`

(

- `dir`

)
Array

Defined in `lib/utils.js:311`

Walks the tree from this dir and returns all the subdirs

#### Parameters:

- `dir` String

  The dir to begin at

#### Returns:

Array: The array of directories..

### `getLayouts`

(

- `dir`

)
Object

Defined in `lib/utils.js:65`

Like `getPages()`, but returns only the files under the `layout/` subdirectory of the specified dir.

#### Parameters:

- `dir` String

  Directory path.

#### Returns:

Object: Mapping of layout names to layout content.

### `getPage`

(

- `pagePath`

)
String | Null

Defined in `lib/utils.js:78`

Loads and returns the content of the specified page file.

#### Parameters:

- `pagePath` String

  Path to a single `.handlebars` page.

#### Returns:

String | Null: Page content, or `null` if not found.

### `getPages`

(

- `dir`

)
Object

Defined in `lib/utils.js:91`

Loads pages (files with a `.handlebars` extension) in the specified directory and returns an object containing a mapping of page names (the part of the filename) preceding the `.handlebars` extension) to page content.

#### Parameters:

- `dir` String

  Directory path.

#### Returns:

Object: Mapping of page names to page content.

### `getPartials`

(

- `dir`

)
Object

Defined in `lib/utils.js:122`

Like `getPages()`, but returns only the files under the `partial/` subdirectory of the specified dir.

#### Parameters:

- `dir` String

  Directory path.

#### Returns:

Object: Mapping of partial names to partial content.

### `getProjectData`

(

- `[dir=process.cwd()]`

)

Defined in `lib/utils.js:225`

Walk the directory tree to locate the yuidoc.json file.

#### Parameters:

- `[dir=process.cwd()]` Path optional

  The directory to start from

### `prepare`

(

- `inDir`
- `options`
- `callback`

)

Defined in `lib/utils.js:136`

Mix/merge/munge data into the template.

#### Parameters:

- `inDir` String

  The starting directory

- `options` Object

  The `options` for the meta data.

- `callback` Callback

  The callback to excecute when complete

  - `err` Error
  - `options` Object

    Merged options.

### `unindent`

(

- `content`

)
String private

Defined in `lib/utils.js:44`

Normalizes the initial indentation of the given content so that the first line is unindented, and all other lines are unindented to the same degree as the first line. So if the first line has four spaces at the beginning, then all lines will be unindented four spaces.

#### Parameters:

- `content` String

  Text to unindent.

#### Returns:

String: Unindented text.

### `validatePaths`

(

- `paths`
- `[ignore=false]`

)

Defined in `lib/utils.js:338`

Make sure all the paths passed are directories and that they are not in the ignore list.

#### Parameters:

- `paths` Array

  The array of paths to validate

- `[ignore=false]` String optional

  A string to call `.indexOf` on a path to determine if it should be ignored