Skip to content

Commit

Permalink
Merge pull request #17304 from colemanw/endCode
Browse files Browse the repository at this point in the history
Switch docblock code to use markdown syntax.
  • Loading branch information
eileenmcnaughton authored May 18, 2020
2 parents c839fad + 0b882a8 commit fdf73b0
Show file tree
Hide file tree
Showing 45 changed files with 146 additions and 144 deletions.
11 changes: 6 additions & 5 deletions CRM/Admin/Page/APIExplorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ private static function getDocBlock($entity, $action) {

/**
* Format a docblock to be a bit more readable
* Not a proper doc parser... patches welcome :)
*
* FIXME: APIv4 uses markdown in code docs. Switch to that.
*
* @param string $text
* @return string
Expand All @@ -224,8 +225,8 @@ public static function formatDocBlock($text) {

// Extract code blocks - save for later to skip html conversion
$code = [];
preg_match_all('#@code(.*?)@endcode#is', $text, $code);
$text = preg_replace('#@code.*?@endcode#is', '<pre></pre>', $text);
preg_match_all('#(@code|```)(.*?)(@endcode|```)#is', $text, $code);
$text = preg_replace('#(@code|```)(.*?)(@endcode|```)#is', '<pre></pre>', $text);

// Convert @annotations to titles
$text = preg_replace_callback(
Expand All @@ -242,8 +243,8 @@ function($matches) {
$text = nl2br($text);

// Add unformatted code blocks back in
if ($code && !empty($code[1])) {
foreach ($code[1] as $block) {
if ($code && !empty($code[2])) {
foreach ($code[2] as $block) {
$text = preg_replace('#<pre></pre>#', "<pre>$block</pre>", $text, 1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2858,11 +2858,11 @@ public function setApiFilter(&$params) {
* Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity
*
* Return format is in the form of fieldname => clauses starting with an operator. e.g.:
* @code
* ```
* array(
* 'location_type_id' => array('IS NOT NULL', 'IN (1,2,3)')
* )
* @endcode
* ```
*
* Note that all array keys must be actual field names in this entity. Use subqueries to filter on other tables e.g. custom values.
*
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Page/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
/**
* Placeholder page which generates a redirect
*
* @code
* ```
* <item>
* <path>civicrm/admin/options/case_type</path>
* <page_callback>CRM_Core_Page_Redirect</page_callback>
* <page_arguments>url=civicrm/foo/bar?whiz=bang&amp;passthru=%%passthru%%</page_arguments>
* </item>
* @endcoe
* ```
*/
class CRM_Core_Page_Redirect extends CRM_Core_Page {

Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct($name) {
/**
* Add a snippet of content to a region.
*
* @code
* ```
* CRM_Core_Region::instance('page-header')->add(array(
* 'markup' => '<div style="color:red">Hello!</div>',
* ));
Expand All @@ -81,7 +81,7 @@ public function __construct($name) {
* CRM_Core_Region::instance('page-header')->add(array(
* 'callback' => 'myextension_callback_function',
* ));
* @endcode
* ```
*
* Note: This function does not perform any extra encoding of markup, script code, or etc. If
* you're passing in user-data, you must clean it yourself.
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ public function addTemplateDir($path) {
/**
* Temporarily assign a list of variables.
*
* @code
* ```
* $smarty->pushScope(array(
* 'first_name' => 'Alice',
* 'last_name' => 'roberts',
* ));
* $html = $smarty->fetch('view-contact.tpl');
* $smarty->popScope();
* @endcode
* ```
*
* @param array $vars
* (string $name => mixed $value).
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Smarty/plugins/block.crmScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*
* Example:
*
* @code
* ```
* {tsScope x=1}
* Expect {$x}==1
* {tsScope x=2}
* Expect {$x}==2
* {/tsScope}
* Expect {$x}==1
* {/tsScope}
* @endcode
* ```
*
* @param array $params
* Must define 'name'.
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Smarty/plugins/function.crmVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
/**
* Display the CiviCRM version
*
* @code
* ```
* The version is {crmVersion}.
*
* {crmVersion redact=auto assign=ver}The version is {$ver}.
* @endcode
* ```
*
* @param $params
* @param $smarty
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/TemporaryErrorScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*
* To ensure that they throw exceptions, use:
*
* @code
* ```
* $errorScope = CRM_Core_TemporaryErrorScope::useException();
* @endcode
* ```
*
* Note that relying on this is a code-smell: it can be
* safe to temporarily switch to exception
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* Examples:
*
* @code
* ```
* // Some business logic using the helper functions
* function my_business_logic() {
* CRM_Core_Transaction::create()->run(function($tx) {
Expand Down Expand Up @@ -60,7 +60,7 @@
* }
* }
*
* @endcode
* ```
*
* Note: As of 4.6, the transaction manager supports both reference-counting and nested
* transactions (SAVEPOINTs). In the past, it only supported reference-counting. The two cases
Expand Down
4 changes: 2 additions & 2 deletions CRM/Queue/ErrorPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* To ensure that PHP errors or unhandled exceptions are reported in JSON
* format, wrap this around your code. For example:
*
* @code
* ```
* $errorContainer = new CRM_Queue_ErrorPolicy();
* $errorContainer->call(function() {
* ...include some files, do some work, etc...
* });
* @endcode
* ```
*
* Note: Most of the code in this class is pretty generic vis-a-vis error
* handling -- except for 'reportError', whose message format is only
Expand Down
4 changes: 2 additions & 2 deletions CRM/Queue/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* different queue-providers may store the queue content in different
* ways (in memory, in SQL, or in an external service).
*
* @code
* ```
* $queue = CRM_Queue_Service::singleton()->create(array(
* 'type' => 'interactive',
* 'name' => 'upgrade-tasks',
Expand All @@ -31,7 +31,7 @@
* $queue->releaseItem($item);
* }
* }
* @endcode
* ```
*/
class CRM_Queue_Service {

Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/API/MatchOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* - "match-mandatory" will generate an error
* - "match" will allow action to proceed -- thus inserting a new record
*
* @code
* ```
* $result = civicrm_api('contact', 'create', array(
* 'options' => array(
* 'match' => array('last_name', 'first_name')
Expand All @@ -30,7 +30,7 @@
* 'last_name' => 'Lebowski',
* 'nick_name' => 'The Dude',
* ));
* @endcode
* ```
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/API/ReloadOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* Implement the "reload" option. This option can be used with "create" to force
* the API to reload a clean copy of the entity before returning the result.
*
* @code
* ```
* $clean = civicrm_api('myentity', 'create', array(
* 'options' => array(
* 'reload' => 1
* ),
* ));
* @endcode
* ```
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
Expand Down
8 changes: 4 additions & 4 deletions CRM/Utils/AutoClean.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class CRM_Utils_AutoClean {
/**
* Call a cleanup function when the current context shuts down.
*
* @code
* ```
* function doStuff() {
* $ac = CRM_Utils_AutoClean::with(function(){
* MyCleanup::doIt();
* });
* ...
* }
* @endcode
* ```
*
* @param mixed $callback
* @return CRM_Utils_AutoClean
Expand All @@ -52,12 +52,12 @@ public static function with($callback) {
* Temporarily swap values using callback functions, and cleanup
* when the current context shuts down.
*
* @code
* ```
* function doStuff() {
* $ac = CRM_Utils_AutoClean::swap('My::get', 'My::set', 'tmpValue');
* ...
* }
* @endcode
* ```
*
* @param mixed $getter
* Function to lookup current value.
Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/ConsoleTee.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
/**
* Capture the output from the console, copy it to a file, and pass it on.
*
* @code
* ```
* $tee = CRM_Utils_ConsoleTee::create()->start();
* echo "hello world";
* $tee->stop();
* assertEquals("hello world", file_get_contents($tee->getFileName()));
* @endCode
* ```
*
* Loosely speaking, it serves a similar purpose to Unix `tee`.
*
Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/FakeObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* This is a quick-and-dirty way to define a vaguely-class-ish structure. It's non-performant, abnormal,
* and not a complete OOP system. Only use for testing/mocking.
*
* @code
* ```
* $object = new CRM_Utils_FakeObject(array(
* 'doIt' => function() { print "It!\n"; }
* ));
* $object->doIt();
* @endcode
* ```
*/
class CRM_Utils_FakeObject {

Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/GlobalStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Temporarily change a global variable.
*
* @code
* ```
* $globals = CRM_Utils_GlobalStack::singleton();
* $globals->push(array(
* '_GET' => array(
Expand All @@ -26,7 +26,7 @@
* ));
* ...do stuff...
* $globals->pop();
* @endcode
* ```
*
* Note: for purposes of this class, we'll refer to the array passed into
* push() as a frame.
Expand Down
17 changes: 9 additions & 8 deletions CRM/Utils/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2234,10 +2234,8 @@ public static function alterResourceSettings(&$data) {
* If omitted, default to "array('civicrm/a')" for backward compat.
* For a utility that should only be loaded on-demand, use "array()".
* For a utility that should be loaded in all pages use, "array('*')".
* @return null
* the return value is ignored
*
* @code
* ```
* function mymod_civicrm_angularModules(&$angularModules) {
* $angularModules['myAngularModule'] = array(
* 'ext' => 'org.example.mymod',
Expand All @@ -2252,7 +2250,10 @@ public static function alterResourceSettings(&$data) {
* 'basePages' => array('civicrm/a'),
* );
* }
* @endcode
* ```
*
* @return null
* the return value is ignored
*/
public static function angularModules(&$angularModules) {
return self::singleton()->invoke(['angularModules'], $angularModules,
Expand All @@ -2266,7 +2267,7 @@ public static function angularModules(&$angularModules) {
*
* @param \Civi\Angular\Manager $angular
*
* @code
* ```
* function example_civicrm_alterAngular($angular) {
* $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
* ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
Expand All @@ -2275,7 +2276,7 @@ public static function angularModules(&$angularModules) {
* );
* $angular->add($changeSet);
* }
* @endCode
* ```
*/
public static function alterAngular($angular) {
$event = \Civi\Core\Event\GenericHookEvent::create([
Expand Down Expand Up @@ -2365,15 +2366,15 @@ public static function crudLink($spec, $bao, &$link) {
/**
* Modify the CiviCRM container - add new services, parameters, extensions, etc.
*
* @code
* ```
* use Symfony\Component\Config\Resource\FileResource;
* use Symfony\Component\DependencyInjection\Definition;
*
* function mymodule_civicrm_container($container) {
* $container->addResource(new FileResource(__FILE__));
* $container->setDefinition('mysvc', new Definition('My\Class', array()));
* }
* @endcode
* ```
*
* Tip: The container configuration will be compiled/cached. The default cache
* behavior is aggressive. When you first implement the hook, be sure to
Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/Migrate/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CRM_Utils_Migrate_Export {
* @var array
* Description of export field mapping
*
* @code
* ```
* 'exampleEntityMappingName' => array(
* 'data' => array(), // placeholder; this will get filled-in during execution
* 'name' => 'CustomGroup', // per-item XML tag name
Expand All @@ -31,7 +31,7 @@ class CRM_Utils_Migrate_Export {
* 'idNameFields' => array('id', 'name'), // name of the (local/autogenerated) "id" and (portable) "name" columns
* 'idNameMap' => array(), // placeholder; this will get filled-in during execution
* ),
* @endcode
* ```
*/
protected $_xml;

Expand Down
Loading

0 comments on commit fdf73b0

Please sign in to comment.