PHPackages                             jamiehannaford/doc-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jamiehannaford/doc-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

jamiehannaford/doc-validator
============================

Simple scraper for validating nested XML/JSON examples in HTML

1.0.0(12y ago)125Apache-2.0PHPPHP &gt;=5.4

Since Feb 26Pushed 12y ago1 watchersCompare

[ Source](https://github.com/jamiehannaford/doc-validator)[ Packagist](https://packagist.org/packages/jamiehannaford/doc-validator)[ RSS](/packages/jamiehannaford-doc-validator/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

doc-validator
=============

[](#doc-validator)

Simple scraper for validating nested XML/JSON examples in OpenStack/Rackspace doc files.

General outline
---------------

[](#general-outline)

1. Executes a recursive wget for a given URI. The process follows every link nested in a given piece of markup until every possible link is exhausted. It saves each remote URI to the local filesystem. An example location might be: `./docs/docs.openstack.org`, where `docs.openstack.org` is the root URI you specified. Only HTML files are saved, any other remote file type is omitted.
2. Once the wget procedure is complete, the PHP script traverses the local directory recursively, scanning each HTML file for a given regex pattern. The regular expression indicates how code samples are nested into the markup.
3. Once code samples are extracted, the script judges whether it is either JSON or XML. It then executes the relevant parsing test for either type.
4. If the parsing fails, it is likely malformed, and generates an error. These errors can either be output to the console (i.e. STDOUT) or to a local log file.

CLI options
-----------

[](#cli-options)

The main script you will need to run is:

```
./bin/doc-validator
```

### Supported CLI flags

[](#supported-cli-flags)

ShortLongDescriptionDefault`-u``--uri`The URI which wget points atdocs.rackspace.com`-s``--skip-wget`Instructs the script to skip the wget stage and check the local `./docs` version onlyDisabled`-q``--quiet-wget`Instructs the script to silence the wget outputDisabled`-l``--log-file`Instructs the script to output everything to a provided file. If left empty, the filename will be the same as the root URIDisabled### Convenience scripts

[](#convenience-scripts)

To run against docs.openstack.org, run: `./bin/openstack`

To run against docs.rackspace.com, run: `./bin/rackspace`

Installation
------------

[](#installation)

You will need to install this package with Composer:

```
# Install Composer executable
curl -sS https://getcomposer.org/installer | php

# Install package
php composer.phar require jamiehannaford/doc-validator:1.0.0
```

You can then access the binary:

```
./vendor/bin/doc-validator -udocs.foo.com -q -l
