From bf10cca1dba9bac79057ef605485baef2c7902b3 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Thu, 16 Sep 2021 08:47:22 -0500 Subject: [PATCH] Added documentation for Grammar to readme --- README.md | 184 ++++++++++-------------------------------------------- 1 file changed, 34 insertions(+), 150 deletions(-) diff --git a/README.md b/README.md index 65db393..a035374 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,38 @@ Lit is a multilanguage syntax highlighter written in PHP. It takes code as input ## Documentation ## +### dW\\Lit\\Grammar::__construct ### + +Creates a new `dW\Lit\Grammar` object. + +```php +public function dW\Lit\Grammar::__construct(?string $scopeName = null, ?array $patterns = null, ?string $name = null, ?array $injections = null, ?array $repository = null) +``` + +#### Parameters #### + +In normal usage of the library the parameters won't be used (see `dW\Lit\Grammar::loadJSON` and examples below for more information), but they are listed below for completeness' sake. + +***scopeName*** - The scope name of the grammar +***patterns*** - The list of patterns in the grammar +***name*** - A human-readable name for the grammar +***injections*** - The list of injections in the grammar +***repository*** - The list of repository items in the grammar + + +### dW\\Lit\\Grammar::loadJSON ### + +Imports an Atom JSON grammar into the `dW\Lit\Grammar` object. + +```php +public function dW\Lit\Grammar::loadJSON(string $filename) +``` + +#### Parameters #### + +***filename*** - The JSON file to be imported + + ### dW\\Lit\\Highlight::toElement ### Highlights incoming string data and outputs a PHP `DOMElement`. @@ -48,159 +80,11 @@ echo $element->ownerDocument->saveHTML($element); This will produce: - +```html
<?php
 echo "OOK!";
 ?>
+``` An existing `DOMDocument` may be used as the owner document of the returned `pre` element: