├── icon.png ├── .gitignore ├── README.md ├── travis.sh ├── .travis.yml ├── run.sh ├── phpxref.cfg └── generate-dokuwiki.php /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamma/dokuwiki-dash-docset/master/icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | DokuWiki.docset 2 | Thumbs.db 3 | desktop.ini 4 | .DS_Store 5 | .buildpath 6 | .project 7 | .settings 8 | output 9 | dokuwiki 10 | phpxref* 11 | dokuwiki-docset.tgz 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DokuWiki Dash 2 | ============= 3 | 4 | Generates a [Dash](http://kapeli.com/dash) docset for [DokuWiki](http://www.dokuwiki.org). 5 | 6 | [![Travis Build State](https://travis-ci.org/gamma/dokuwiki-dash-docset.svg)](https://travis-ci.org/gamma/dokuwiki-dash-docset) 7 | 8 | Build 9 | ----- 10 | 11 | To build the Docset, just run the following scripts in that order: 12 | 13 | sh travis.sh 14 | sh run.sh 15 | 16 | Beware: This has to be done on either Travis or a system sporting a case sensitive file system. 17 | -------------------------------------------------------------------------------- /travis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | # 3 | # This script will download phpXref and the master Branch of DokuWiki 4 | # from which it will create the documentation and the DocSet 5 | # @author: Gerry Weißbach 6 | 7 | echo "> LOADING PHPXRef" 8 | git clone --depth=1 https://github.com/gamma/phpxref.git ./phpxref 9 | cp -a ./phpxref.cfg ./phpxref 10 | 11 | # checkout DokuWiki into current directory (no clone because dir isn't empty) 12 | # the branch is specified in the $DOKUWIKI environment variable 13 | echo "> CLONING DOKUWIKI: ${DOKUWIKI:-master}" 14 | mkdir -p dokuwiki && cd dokuwiki && git init 15 | git pull https://github.com/splitbrain/dokuwiki.git "${DOKUWIKI:-master}" 16 | 17 | # remove not needed language files 18 | echo "> Removing not needed language files" 19 | find . -name "lang" -type d -exec find {} -type d -not -name "en" \; | xargs rm -rf 20 | cd - 21 | 22 | # Create Output Directory for PHPXref 23 | mkdir -p ./output 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - '5.6' 4 | env: 5 | - DOKUWIKI=release_stable_2020-07-29 6 | install: 7 | - sh travis.sh 8 | script: 9 | - sh run.sh 10 | deploy: 11 | provider: releases 12 | api_key: 13 | secure: vem1L+e5n3xngCO7YLF8kyp8xplLqUzbgxP8lQGqdmFjZFlY5iqIogLxZWtxWX7n1ALXskzDT3WOcYmVc1tfdf0di+7SwKDAo1S02mFxkaT7+9GPVf8Zk1E2Xjb1S50JuL2NoklW51kOvmU7Uqx/RqJEwVJxrP1WWsszjg3KkK+6o2oYWai14Ee2s7qXPfKlKuf+/bqU9aXGaA4UntNt5+FCOwdYS+e+166i3j11bnySPIhSWRrW3cFQKJxKljNTviAz+DlTWYP+S51+c7bi7jeIoChIQdxYgdfkdjHtFKQ+eG6LAYv73Oob1DkjF1THSGRJ5c87xtLuBHQclYIu+mnAsgk1yr18Nv26kW1wE5rLhu719guIvm2O75kbS3A8uz+88e9Y2BOi8eGS8K7p3DNgnqVQ2K6XByxRh0qH2qA1deqOVSBSWOFszdEU79S/yLihNEYaFq3QBdcTNpDvqA2d1y4HT/a8UQ6OyTDefxNaaa6Hn4dqSNShtnVku5rYgHtb70y+wVqyiaZl09v4P++/6yHiMrv8AolL7q86hguZjt0Sk5Q+R9KfYXPjBpSHT6OjjR4QdC3MlFH3tCs2xEwLYaIzx/svmknmM/KJnXFW+fGhhJWQWPZ5uoq4ApWpvOLD2/ke9mEEVHwSiNQZUkmIsausgvH71MichtDIe8I= 14 | file: dokuwiki-docset.tgz 15 | on: 16 | repo: gamma/dokuwiki-dash-docset 17 | tags: true 18 | skip_cleanup: 'true' 19 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | # 3 | # This script will download phpXref and the master Branch of DokuWiki 4 | # from which it will create the documentation and the DocSet 5 | # @author: Gerry Weißbach 6 | 7 | if [ -z "$DOKUWIKI" ]; then 8 | DOKUWIKI=$(cat ./.travis.yml | grep "DOKUWIKI=" | awk -F= '{print $2}') 9 | fi 10 | 11 | BRANCH=git rev-parse --abbrev-ref HEAD 12 | if [ -e "./dokuwiki/VERSION" ]; then 13 | BRANCH=$(cat ./dokuwiki/VERSION) 14 | fi 15 | 16 | if [ -z "BRANCH" ]; then 17 | BRANCH=$DOKUWIKI 18 | fi 19 | 20 | VERSION_NAME=$(echo "Dokuwiki $BRANCH" | xargs) 21 | VERSION_PATH=$(echo "$BRANCH" | tr -cd '[:alnum:]_-') 22 | 23 | DASH_CONTRIBUTIONS_PATH="../Dash-User-Contributions" 24 | DASH_DW_CONTRIBUTIONS_PATH="${DASH_CONTRIBUTIONS_PATH}/docsets/DokuWiki" 25 | 26 | # Create PHPXref of DokuWiki 27 | cd ./phpxref/ && perl ./phpxref.pl && cd .. 28 | 29 | # Prepare 30 | DOCUMENT_BASE="${VERSION_NAME}.docset/Contents/Resources" 31 | 32 | # Delete create 33 | rm -rf "$DOCUMENT_BASE" 34 | mkdir -p "$DOCUMENT_BASE" 35 | cp -a ./output "$DOCUMENT_BASE/Documents" 36 | 37 | # Modify Path 38 | export PATH=`echo $PATH | sed -e 's/:\.\/[^:]*//g'` 39 | 40 | # Generate the Docset 41 | php generate-dokuwiki.php "${VERSION_NAME}" 42 | 43 | # Package the Docset 44 | tar --exclude='.DS_Store' -czf dokuwiki-docset.tgz "${VERSION_NAME}.docset" 45 | 46 | if [ -d "${DASH_CONTRIBUTIONS_PATH}" ]; then 47 | echo "Will copy docset file to Dash-User-Contributions" 48 | cp dokuwiki-docset.tgz "${DASH_DW_CONTRIBUTIONS_PATH}/" 49 | 50 | mkdir -p "${DASH_DW_CONTRIBUTIONS_PATH}/versions/${VERSION_PATH}/" 51 | cp dokuwiki-docset.tgz "${DASH_DW_CONTRIBUTIONS_PATH}/versions/${VERSION_PATH}/" 52 | fi 53 | 54 | # Clean Up 55 | rm -rf "./phpxref/" output dokuwiki 56 | 57 | # Show everything 58 | ls -altr * 59 | ls -altr */* 60 | ls -altr */*/* 61 | 62 | du -sh * 63 | -------------------------------------------------------------------------------- /phpxref.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Sample configuration file for phpxref v0.7.1 3 | # 4 | # Be sure to read the README.html file for information 5 | # on using PHPXref 6 | 7 | # The base directory containing all of your PHP code to be indexed 8 | # This could just be a directory containing symlinks to the real directories 9 | #SOURCE=C:\webserver\sites\www.myhost.com\htdocs 10 | SOURCE=../dokuwiki 11 | 12 | # The directory in which you'd like the output to be written 13 | #OUTPUT=C:\phpxref\output 14 | OUTPUT=../output 15 | 16 | # Project name; something short 17 | PROJECT=DokuWiki 18 | 19 | # Cookie key - If you have multiple phpxref projects on the same server 20 | # (or on your local machine) then things like the search history will 21 | # benefit from having a different key here for each project 22 | # It can be any short string; as long as it's unique 23 | COOKIE=phpxref 24 | 25 | # Name of the HTML file to prepend to the output 26 | HEADERFILE=sample_header.html 27 | 28 | # Name of the HTML file to append to the output 29 | FOOTERFILE=sample_footer.html 30 | 31 | # Names of the stylesheets to copy into the output tree 32 | STYLEFILE=sample.css 33 | PRINTSTYLEFILE=sample-print.css 34 | 35 | # Character set to specify for generated HTML 36 | CHARSET=iso-8859-1 37 | 38 | # Directories, relative to SOURCE, to search for files that have been 39 | # require()'d or include()'d 40 | # ie. works in a similar way to PHP's php_include_path variable 41 | INCLUDEPATH=.:/include:/ 42 | 43 | # Filenames beginning with a period will be ignored if this is set 44 | NO_HIDDEN=1 45 | 46 | # File extension to use on output pages 47 | EXTENSION=html 48 | 49 | # Set to 1 and install the IO::Zlib perl module to compress all output 50 | # pages. Requires a correctly configured web server to serve the 51 | # resulting files. 52 | COMPRESS=0 53 | 54 | # Set to 1 to link email and web addresses in the summary pages 55 | # This is potentially a cross-site-scripting (XSS) security hole 56 | # if you're running phpxref on untrusted source code 57 | LINK_URI=1 58 | 59 | # Set to 1 to have links in the file explorer open the 60 | # PHP source page, rather than the summary page 61 | EXPLORE_SOURCE=1 62 | 63 | # Cross-reference all mentions of source filenames, not just 64 | # those in require/include statements 65 | # If you find this is too aggressive/verbose, try turning it off 66 | FULLXREF=1 67 | 68 | # File containing a list of PHP functions, one per line 69 | FUNCTIONLIST=php5_functionlist.txt 70 | 71 | # Set this to 0 to enable "traditional" style function comments 72 | # (ie. those that begin with '////' used with old versions of 73 | # phpxref) 74 | NO_TRAD_DOC = 1 75 | 76 | # Don't index files listed in these directories 77 | # You can have multiple BAD_DIRNAME entries if necessary 78 | BAD_DIRNAME=data 79 | BAD_DIRNAME=.git 80 | BAD_DIRNAME=.DS_Store 81 | 82 | # Don't index files matching this whole path 83 | #BAD_PATHNAME=/manual/index.php 84 | 85 | # Ignore files with this filename. Multiple entries are allowed 86 | #BAD_FILENAME=local.inc 87 | 88 | # Ignore files with this extension. Multiple entries are allowed 89 | BAD_EXT=bz2 90 | BAD_EXT=gz 91 | BAD_EXT=zip 92 | BAD_EXT=exe 93 | BAD_EXT=bin 94 | BAD_EXT=dat 95 | BAD_EXT=core 96 | BAD_EXT=gif 97 | BAD_EXT=jpg 98 | BAD_EXT=png 99 | BAD_EXT=prc 100 | BAD_EXT=tgz 101 | BAD_EXT=ico 102 | 103 | # If you'd rather specify which extensions to *include*, instead of 104 | # which to *exclude* (via bad_ext above) then use GOOD_EXT instead: 105 | # GOOD_EXT=php 106 | # GOOD_EXT=phtml 107 | 108 | # Specify which tags you wish to show up along with function/class 109 | # descriptions 110 | # use multiple DOC_TAG entries if you wish to list more than one tag 111 | DOC_TAG=author 112 | DOC_TAG=param 113 | DOC_TAG=return 114 | DOC_TAG=returns 115 | 116 | # Specify which tags you wish to show up for file descriptions 117 | # in the file summary page 118 | DOC_FILE_TAG=author 119 | DOC_FILE_TAG=license 120 | DOC_FILE_TAG=copyright 121 | DOC_FILE_TAG=version 122 | 123 | # Configuration options to let phpxref obtain information about SQL tables 124 | # referenced in your comments. Note this only works with MySQL for the moment 125 | 126 | # Change this to YES to enable this feature 127 | # NOTE - This will not work on Windows if you're using the .exe version of PHPXref 128 | DB_USE=NO 129 | DB_HOST=localhot 130 | DB_PORT=3306 131 | DB_NAME= 132 | DB_USER= 133 | DB_PASS= 134 | 135 | # If the code you are trying to cross reference uses constants or 136 | # variable names when require()ing or include()ing other PHP files 137 | # then you can tell phpxref what those constants/variables should 138 | # be set to here 139 | # Failing to set this will just cause links between different files 140 | # to be missed in situations such as require(HORDE_TEMPLATES.'something.inc') 141 | # 142 | # to set $templates='foo' just do templates='foo' below. 143 | HORDE_BASE=/ 144 | HORDE_TEMPLATES=templates/ 145 | -------------------------------------------------------------------------------- /generate-dokuwiki.php: -------------------------------------------------------------------------------- 1 | 1 ) { 5 | $DOKU_WIKI = $argv[1]; 6 | } else { 7 | $DOKU_WIKI = "DokuWiki"; 8 | } 9 | 10 | define('DOCUMENT_BASE', __DIR__ . "/${DOKU_WIKI}.docset/Contents/Resources/Documents"); 11 | print "DOCUMENT_BASE: " . DOCUMENT_BASE; 12 | global $db; 13 | 14 | 15 | function prepare() { 16 | global $db; 17 | global $DOKU_WIKI; 18 | 19 | file_put_contents(__DIR__ . "/${DOKU_WIKI}.docset/Contents/Info.plist", << 21 | 22 | 23 | 24 | CFBundleIdentifier 25 | org.dokuwiki 26 | CFBundleName 27 | DokuWiki 28 | DocSetPlatformFamily 29 | dokuwiki 30 | isDashDocset 31 | 32 | dashIndexFilePath 33 | index.html 34 | 35 | 36 | ENDE 37 | 38 | // isJavaScriptEnabled 39 | // 40 | 41 | 42 | ); 43 | copy(__DIR__ . "/icon.png", __DIR__ . "/${DOKU_WIKI}.docset/icon.png"); 44 | 45 | $db = new sqlite3(__DIR__ . "/${DOKU_WIKI}.docset/Contents/Resources/docSet.dsidx"); 46 | $db->query("CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT)"); 47 | $db->query("CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path)"); 48 | } 49 | 50 | global $existing; 51 | function existingFile( $type, $key, $href) { 52 | global $existing; 53 | 54 | if ( !is_array($existing) ) $existing = array(); 55 | if ( !array_key_exists($type, $existing) ) $existing[$type] = array(); 56 | 57 | if ( array_key_exists($key, $existing[$type]) ) return $existing[$type][$key]; 58 | if ( !file_exists(DOCUMENT_BASE."/".$href) ) { 59 | print "Skipping: '$type':'$key' -> '$href'"; 60 | return null; 61 | } 62 | 63 | $existing[$type][$key] = $href; 64 | return $href; 65 | } 66 | 67 | function functionReference() { 68 | global $db; 69 | foreach( array( 'Class' => '_classes', 70 | 'Constant' => '_constants', 71 | 'Function' => '_functions', 72 | 'Variable' => '_variables' ) as $type => $location ) { 73 | 74 | $links = array(); 75 | $dom = new DomDocument; 76 | @$dom->loadHTMLFile(DOCUMENT_BASE . '/' . $location . "/index.html"); 77 | 78 | // add links from the table of contents 79 | $stmt = $db->prepare('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (:name,:type,:href)'); 80 | foreach ($dom->getElementsByTagName("a") as $a) { 81 | $href = $a->getAttribute("href"); 82 | $name = $a->getAttribute("name"); 83 | 84 | if ( empty($href) || empty($name) ) { 85 | continue; 86 | } 87 | 88 | $href = existingFile($type, $name, $location . '/' . $href); 89 | if ( is_null( $href ) ) { continue; } 90 | // if ( array_key_exists($href, $links) ) { continue; } 91 | 92 | #print "Found '$type': '$name' - '$href'\n"; 93 | $links[$href] = true; 94 | 95 | $stmt->clear(); 96 | $stmt->bindValue(':name', $name, SQLITE3_TEXT); 97 | $stmt->bindValue(':type', $type, SQLITE3_TEXT); 98 | $stmt->bindValue(':href', $href, SQLITE3_TEXT); 99 | $stmt->execute(); 100 | } 101 | 102 | $stmt->close(); 103 | print "\nFound " . count($links) . " of type: " . $type; 104 | } 105 | } 106 | 107 | 108 | function events() { 109 | global $db; 110 | $events = array(); 111 | $funcList = array( "Doku_Event", "register_hook", "trigger_event"); 112 | $prefixes = implode('|', $funcList); 113 | exec('grep -RE -e "('.$prefixes.')[^\'\"].*?\([\'\"]" --include "*.html" --exclude-dir "_test" "' . DOCUMENT_BASE . '"', $events); 114 | foreach( $events as $line ) { 115 | 116 | list($file, $command) = explode( ':', $line, 2); 117 | 118 | $file = str_replace(DOCUMENT_BASE, '', $file); $matches = array(); 119 | if ( !preg_match("/($prefixes)[^'\"].*?\([\'\"](.*?)[\'\"]\s?[,\)]/", $command, $matches) ) { 120 | continue; 121 | } 122 | 123 | $func = $matches[1]; 124 | $evnt = $matches[2]; 125 | 126 | if ( !array_key_exists($evnt, $events) || array_search( $events[$evnt]['func'], $funcList ) > array_search( $func, $funcList ) ) { 127 | $events[$evnt] = array( 128 | 'file' => $file, 129 | 'func' => $func 130 | ); 131 | } 132 | } 133 | 134 | $stmt = $db->prepare('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (:name,"Event",:href)'); 135 | foreach( $events as $event => $data ) { 136 | 137 | if ( !is_array($data) ) { continue; } 138 | $stmt->clear(); 139 | $stmt->bindValue(':name', $event, SQLITE3_TEXT); 140 | $stmt->bindValue(':href', $data['file'], SQLITE3_TEXT); 141 | $stmt->execute(); 142 | } 143 | 144 | $stmt->close(); 145 | } 146 | 147 | function files() { 148 | global $db; 149 | 150 | $files = array(); 151 | 152 | print "\n\n"; 153 | exec('find "'.DOCUMENT_BASE.'" -type f -name "*.source.html"', $files); 154 | 155 | $stmt = $db->prepare('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (:name,"File",:href)'); 156 | foreach( $files as $href ) { 157 | $href = str_replace(DOCUMENT_BASE, '', $href); 158 | $file = str_replace('.source.html', '', $href); 159 | $matches = array(); 160 | 161 | $stmt->clear(); 162 | $stmt->bindValue(':name', $file, SQLITE3_TEXT); 163 | $stmt->bindValue(':href', $href, SQLITE3_TEXT); 164 | $stmt->execute(); 165 | } 166 | 167 | $stmt->close(); 168 | print "\n\n"; 169 | } 170 | 171 | prepare(); 172 | functionReference(); 173 | events(); 174 | files(); 175 | print "\n\n"; 176 | --------------------------------------------------------------------------------