PHP Documentation Parser

When I was making PHP Ninja Manual I had to make one by-product that converts entire PHP documentation into some structured format that can be indexed by Web SQL database. Since I couldn't find anything useful for me that time I made a simple parser which takes PHP docmentation in "many HTML files" format and generates one big JSON array that is part of the Chrome extension.

A few people asked me how I generated the JSON database so I'm putting everything on GitHub. Feel free to modify or reuse any part, it's distributed under beerware licence.

I think generated JSON structure is very simple:

 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
 37 
 38 
 39 
 40 
 41 
 42 
 43 
 44 
 45 
 46 
 47 
 48 
 49 
 50 
 51 
 52 
 53 
 54 
 55 
 56 
 57 
 58 
 59 
 60 
 61 
 62 
 63 
 64 
 65 
 66 
{
  ...
  "str_pad": { ... }
  "str_repeat": { ... }
  "str_replace":
    {
      "desc":"Replace all occurrences of the search string with the replacement string",
      "long_desc":"This function returns a string or an array with all occurrences of search in subject replaced with the given replace value. If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of preg_replace().",
      "ver":"PHP 4, PHP 5",
      "ret_desc":"This function returns a string or an array with the replaced values.",
      "seealso":[
        {
          "name":"str_ireplace",
          "desc":"Case"
        },
        {
          "name":"substr_replace",
          "desc":"Replace text within a portion of a string"
        },
        {
          "name":"preg_replace",
          "desc":"Perform a regular expression search and replace"
        },
        {
          "name":"strtr",
          "desc":"Translate characters or replace substrings"
        }
      ],
      "url":"function.str-replace",
      "name":"str_replace",
      "params":[
        {
          "list":[
            {
              "type":"mixed",
              "var":"$search",
              "beh":0,
              "desc":"The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles."
            },
            {
              "type":"mixed",
              "var":"$replace",
              "beh":1,
              "desc":"The replacement value that replaces found search values. An array may be used to designate multiple replacements."
            },
            {
              "type":"mixed",
              "var":"$subject",
              "beh":1,
              "desc":"The string or array being searched and replaced on, otherwise known as the haystack. If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well."
            },
            {
              "type":"int",
              "var":"&$count",
              "beh":1,
              "desc":"If passed, this will be set to the number of replacements performed."
            }
          ],
          "ret_type":"mixed"
        }
      ]
    },
  "str_rot13": { ... },
  "str_shuffle": { ... },
  ....
}

For more information and all source codes see PHP Documentation Parser on GitHub.

blog comments powered by Disqus