protected function addDocumentation()
    {
        $docDirectory = $this->getDocumentationDirectory();

        // If there's a documentation directory
        if (is_dir($docDirectory)) {
            $validIndexDocuments = [
                'index.md',
                'readme.md',
                strtolower($this->basename.'.md')
            ];
            $indexDocument       = null;
            $documents           = [];

            // Run through all documentation files
            foreach (scandir($docDirectory) as $document) {
                if (!is_file($docDirectory.DIRECTORY_SEPARATOR.$document)) {
                    continue;
                }

                // If there's a valid documentation index file
                if (in_array(strtolower($document), $validIndexDocuments)) {
                    if ($indexDocument === null) {
                        $indexDocument = $docDirectory.DIRECTORY_SEPARATOR.$document;
                    }
                    continue;
                }

                $documents[] = $docDirectory.DIRECTORY_SEPARATOR.$document;
            }

            // If there's an index document
            if ($indexDocument !== null) {
                $this->addNotice(file_get_contents($indexDocument));

                return;
            }

            // If there are remaining documents: Auto-create a simple listing
            if (count($documents)) {
                $listing = [];

                // Run through all documents
                foreach ($documents as $document) {
                    $extension = strtolower(pathinfo($document, PATHINFO_EXTENSION));
                    $listing[] = '* '.(in_array($extension, ['jpg', 'jpeg', 'png', 'gif', 'svg']) ? '!' : '').
                                 '['.pathinfo($document, PATHINFO_FILENAME).']('.basename($document).')';
                }

                $this->addNotice(implode(PHP_EOL, $listing));
            }
        }
    }
protected function addDocumentation()
    {
        $docDirectory = $this->getDocumentationDirectory();

        // If there's a documentation directory
        if (is_dir($docDirectory)) {
            $validIndexDocuments = [
                'index.md',
                'readme.md',
                strtolower($this->basename.'.md')
            ];
            $indexDocument       = null;
            $documents           = [];

            // Run through all documentation files
            foreach (scandir($docDirectory) as $document) {
                if (!is_file($docDirectory.DIRECTORY_SEPARATOR.$document)) {
                    continue;
                }

                // If there's a valid documentation index file
                if (in_array(strtolower($document), $validIndexDocuments)) {
                    if ($indexDocument === null) {
                        $indexDocument = $docDirectory.DIRECTORY_SEPARATOR.$document;
                    }
                    continue;
                }

                $documents[] = $docDirectory.DIRECTORY_SEPARATOR.$document;
            }

            // If there's an index document
            if ($indexDocument !== null) {
                $this->addNotice(file_get_contents($indexDocument));

                return;
            }

            // If there are remaining documents: Auto-create a simple listing
            if (count($documents)) {
                $listing = [];

                // Run through all documents
                foreach ($documents as $document) {
                    $extension = strtolower(pathinfo($document, PATHINFO_EXTENSION));
                    $listing[] = '* '.(in_array($extension, ['jpg', 'jpeg', 'png', 'gif', 'svg']) ? '!' : '').
                                 '['.pathinfo($document, PATHINFO_FILENAME).']('.basename($document).')';
                }

                $this->addNotice(implode(PHP_EOL, $listing));
            }
        }
    }
protected function addDocumentation ( ) { $ docDirectory = $ this -> getDocumentationDirectory ( ) ; // If there's a documentation directory if ( is_dir ( $ docDirectory ) ) { $ validIndexDocuments = [ 'index.md' , 'readme.md' , strtolower ( $ this -> basename . '.md' ) ] ; $ indexDocument = null ; $ documents = [ ] ; // Run through all documentation files foreach ( scandir ( $ docDirectory ) as $ document ) { if ( ! is_file ( $ docDirectory . DIRECTORY_SEPARATOR . $ document ) ) { continue ; } // If there's a valid documentation index file if ( in_array ( strtolower ( $ document ) , $ validIndexDocuments ) ) { if ( $ indexDocument === null ) { $ indexDocument = $ docDirectory . DIRECTORY_SEPARATOR . $ document ; } continue ; } $ documents [ ] = $ docDirectory . DIRECTORY_SEPARATOR . $ document ; } // If there's an index document if ( $ indexDocument !== null ) { $ this -> addNotice ( file_get_contents ( $ indexDocument ) ) ; return ; } // If there are remaining documents: Auto-create a simple listing if ( count ( $ documents ) ) { $ listing = [ ] ; // Run through all documents foreach ( $ documents as $ document ) { $ extension = strtolower ( pathinfo ( $ document , PATHINFO_EXTENSION ) ) ; $ listing [ ] = '* ' . ( in_array ( $ extension , [ 'jpg' , 'jpeg' , 'png' , 'gif' , 'svg' ] ) ? '!' : '' ) . '[' . pathinfo ( $ document , PATHINFO_FILENAME ) . '](' . basename ( $ document ) . ')' ; } $ this -> addNotice ( implode ( PHP_EOL , $ listing ) ) ; } } }
Add an external documentation
Add an external documentation