PageRenderTime 34ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/sample/usage.php

https://github.com/pop/pop_doc
PHP | 47 lines | 28 code | 8 blank | 11 comment | 0 complexity | 9695628f13c8e41a889a4cdcccbf16d4 MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright (c) 2008, SARL Adaltas. All rights reserved.
  4. * Code licensed under the BSD License:
  5. * http://www.php-pop.org/porte/license.html
  6. */
  7. require(dirname(__FILE__).'/../../pur/src/pur.inc.php');
  8. require(dirname(__FILE__).'/../src/pop_doc.inc.php');
  9. /** Exemple start here ****************************************/
  10. // Construction from a file path
  11. $path = dirname(__FILE__).'/usage.md';
  12. $doc = new PopDoc();
  13. $doc->path($path);
  14. assert( is_string( $doc->title ) );
  15. assert( is_string( $doc->toHtml() ) );
  16. assert( is_string( $doc->toText() ) );
  17. // Construction from a formated content
  18. $path = dirname(__FILE__).'/usage.md';
  19. $content = file_get_contents($path);
  20. $doc = new PopDoc();
  21. $doc->content($content);
  22. assert( is_string( $doc->title ) );
  23. assert( is_string( $doc->toHtml() ) );
  24. assert( is_string( $doc->toText() ) );
  25. // Construction from parsed data
  26. $path = dirname(__FILE__).'/usage.md';
  27. $content = file_get_contents($path);
  28. $data = PopDocParser::parse($content);
  29. $doc = new PopDoc();
  30. $doc->data($data);
  31. assert( is_string( $doc->title ) );
  32. assert( is_string( $doc->toHtml() ) );
  33. assert( is_string( $doc->toText() ) );
  34. // Chained construction
  35. $doc = PopDoc
  36. ::newInstance()
  37. ->content("My Title\n========");
  38. assert( 'My Title' === $doc->title );
  39. /** Exemple stop here ****************************************/