/sample/usage.php
PHP | 47 lines | 28 code | 8 blank | 11 comment | 0 complexity | 9695628f13c8e41a889a4cdcccbf16d4 MD5 | raw file
- <?php
- /**
- * Copyright (c) 2008, SARL Adaltas. All rights reserved.
- * Code licensed under the BSD License:
- * http://www.php-pop.org/porte/license.html
- */
-
- require(dirname(__FILE__).'/../../pur/src/pur.inc.php');
- require(dirname(__FILE__).'/../src/pop_doc.inc.php');
- /** Exemple start here ****************************************/
- // Construction from a file path
- $path = dirname(__FILE__).'/usage.md';
- $doc = new PopDoc();
- $doc->path($path);
- assert( is_string( $doc->title ) );
- assert( is_string( $doc->toHtml() ) );
- assert( is_string( $doc->toText() ) );
- // Construction from a formated content
- $path = dirname(__FILE__).'/usage.md';
- $content = file_get_contents($path);
- $doc = new PopDoc();
- $doc->content($content);
- assert( is_string( $doc->title ) );
- assert( is_string( $doc->toHtml() ) );
- assert( is_string( $doc->toText() ) );
- // Construction from parsed data
- $path = dirname(__FILE__).'/usage.md';
- $content = file_get_contents($path);
- $data = PopDocParser::parse($content);
- $doc = new PopDoc();
- $doc->data($data);
- assert( is_string( $doc->title ) );
- assert( is_string( $doc->toHtml() ) );
- assert( is_string( $doc->toText() ) );
- // Chained construction
- $doc = PopDoc
- ::newInstance()
- ->content("My Title\n========");
- assert( 'My Title' === $doc->title );
-
- /** Exemple stop here ****************************************/