owncloud / docs

ownCloud Documentation (v2)
https://doc.owncloud.com
GNU Affero General Public License v3.0
56 stars 89 forks source link

Unincluded (orphaned) example files in developer_manual #792

Closed mmattel closed 5 years ago

mmattel commented 5 years ago

What Needs to be Documented?

Unincluded example files found in developer manual (orphaned)

Where Does This Need To Be Documented?

These files should be either:

We may have to check the old documentation...

Why Should This Change Be Made? (Optional)

Doc Quality

What Type Of Content Change Is This? (Optional)

Which Manual Does This Relate To? (Optional)

Script used

#!/usr/bin/env php
<?php

#$module = "admin_manual";
$module = "developer_manual";
#$module = "user_manual";
$path_to_examples = "modules/$module/examples";
$path_to_pages = "modules/$module/pages";
$include_ex_dir = ":include::{examplesdir}";
$tmp = "";
$ex_files = [];
$found_include_files = [];
$found_include_link = [];
$lost_link =[] ;

$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path_to_examples, RecursiveDirectoryIterator::SKIP_DOTS));
$fp = \iterator_to_array($it, false);

echo "get all example files in: $path_to_examples" . "\n";
foreach($fp as $path) {
  $tmp = \preg_replace('/^.+\n/', '', $path);
  $ex_files[] = \str_replace($path_to_examples, "", $tmp);
}

echo "grep for include::{examplesdir} in: $path_to_pages" . "\n";
$cmd = "grep -r " . "'" . "include::{examplesdir}/" . "' " . $path_to_pages ;
$subject = \trim(\shell_exec($cmd)); # string
$line = \explode("\n", $subject);

# only if array is multidimensional = grep found something;
foreach($line as $aline) {
  $fif = \explode($include_ex_dir, $aline);
  # only if there was a $include_ex_dir found
  if (isset($fif[1])) {
    # remove anyting like [text] which only occurs at the end of the line
    $fif[1] = preg_replace('/\[.*?\]/', '', $fif[1]);
    $found_include_files[] = $fif[0];
    $found_include_link[] = $fif[1];
  }
}

$lost_link = \array_diff($ex_files, $found_include_link);
$count_found = \count($lost_link);

echo "Found $count_found matching example files which are nowhere included" . "\n\n";
print_r ($lost_link);

?>

Result

get all example files in: modules/developer_manual/examples
grep for include::{examplesdir} in: modules/developer_manual/pages
Found 162 matching example files which are nowhere included

Array
(
    [3] => /app/storage-backend/OCA/MyStorageApp/Backend/MyStorageBackend.php
    [4] => /app/storage-backend/OCA/MyStorageApp/Storage/MyStorage.php
    [12] => /core/scripts/curl/provisioning_api/add-user.curl
    [22] => /core/scripts/php/composer.json
    [23] => /core/scripts/php/composer.lock
    [30] => /core/scripts/php/vendor/autoload.php
    [31] => /core/scripts/php/vendor/composer/ClassLoader.php
    [32] => /core/scripts/php/vendor/composer/LICENSE
    [33] => /core/scripts/php/vendor/composer/autoload_classmap.php
    [34] => /core/scripts/php/vendor/composer/autoload_files.php
    [35] => /core/scripts/php/vendor/composer/autoload_namespaces.php
    [36] => /core/scripts/php/vendor/composer/autoload_psr4.php
    [37] => /core/scripts/php/vendor/composer/autoload_real.php
    [38] => /core/scripts/php/vendor/composer/autoload_static.php
    [39] => /core/scripts/php/vendor/composer/installed.json
    [40] => /core/scripts/php/vendor/guzzlehttp/guzzle/.travis.yml
    [41] => /core/scripts/php/vendor/guzzlehttp/guzzle/CHANGELOG.md
    [42] => /core/scripts/php/vendor/guzzlehttp/guzzle/LICENSE
    [43] => /core/scripts/php/vendor/guzzlehttp/guzzle/README.md
    [44] => /core/scripts/php/vendor/guzzlehttp/guzzle/UPGRADING.md
    [45] => /core/scripts/php/vendor/guzzlehttp/guzzle/composer.json
    [46] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Client.php
    [47] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/ClientInterface.php
    [48] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php
    [49] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php
    [50] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php
    [51] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php
    [52] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php
    [53] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php
    [54] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php
    [55] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php
    [56] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php
    [57] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
    [58] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php
    [59] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php
    [60] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php
    [61] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php
    [62] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
    [63] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php
    [64] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php
    [65] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php
    [66] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php
    [67] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php
    [68] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php
    [69] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
    [70] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/HandlerStack.php
    [71] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/MessageFormatter.php
    [72] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Middleware.php
    [73] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/Pool.php
    [74] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php
    [75] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php
    [76] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/RequestOptions.php
    [77] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php
    [78] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/TransferStats.php
    [79] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/UriTemplate.php
    [80] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/functions.php
    [81] => /core/scripts/php/vendor/guzzlehttp/guzzle/src/functions_include.php
    [82] => /core/scripts/php/vendor/guzzlehttp/promises/.gitignore
    [83] => /core/scripts/php/vendor/guzzlehttp/promises/.travis.yml
    [84] => /core/scripts/php/vendor/guzzlehttp/promises/CHANGELOG.md
    [85] => /core/scripts/php/vendor/guzzlehttp/promises/LICENSE
    [86] => /core/scripts/php/vendor/guzzlehttp/promises/Makefile
    [87] => /core/scripts/php/vendor/guzzlehttp/promises/README.md
    [88] => /core/scripts/php/vendor/guzzlehttp/promises/composer.json
    [89] => /core/scripts/php/vendor/guzzlehttp/promises/phpunit.xml.dist
    [90] => /core/scripts/php/vendor/guzzlehttp/promises/src/AggregateException.php
    [91] => /core/scripts/php/vendor/guzzlehttp/promises/src/CancellationException.php
    [92] => /core/scripts/php/vendor/guzzlehttp/promises/src/Coroutine.php
    [93] => /core/scripts/php/vendor/guzzlehttp/promises/src/EachPromise.php
    [94] => /core/scripts/php/vendor/guzzlehttp/promises/src/FulfilledPromise.php
    [95] => /core/scripts/php/vendor/guzzlehttp/promises/src/Promise.php
    [96] => /core/scripts/php/vendor/guzzlehttp/promises/src/PromiseInterface.php
    [97] => /core/scripts/php/vendor/guzzlehttp/promises/src/PromisorInterface.php
    [98] => /core/scripts/php/vendor/guzzlehttp/promises/src/RejectedPromise.php
    [99] => /core/scripts/php/vendor/guzzlehttp/promises/src/RejectionException.php
    [100] => /core/scripts/php/vendor/guzzlehttp/promises/src/TaskQueue.php
    [101] => /core/scripts/php/vendor/guzzlehttp/promises/src/TaskQueueInterface.php
    [102] => /core/scripts/php/vendor/guzzlehttp/promises/src/functions.php
    [103] => /core/scripts/php/vendor/guzzlehttp/promises/src/functions_include.php
    [104] => /core/scripts/php/vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php
    [105] => /core/scripts/php/vendor/guzzlehttp/promises/tests/CoroutineTest.php
    [106] => /core/scripts/php/vendor/guzzlehttp/promises/tests/EachPromiseTest.php
    [107] => /core/scripts/php/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php
    [108] => /core/scripts/php/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php
    [109] => /core/scripts/php/vendor/guzzlehttp/promises/tests/PromiseTest.php
    [110] => /core/scripts/php/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php
    [111] => /core/scripts/php/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php
    [112] => /core/scripts/php/vendor/guzzlehttp/promises/tests/TaskQueueTest.php
    [113] => /core/scripts/php/vendor/guzzlehttp/promises/tests/Thennable.php
    [114] => /core/scripts/php/vendor/guzzlehttp/promises/tests/bootstrap.php
    [115] => /core/scripts/php/vendor/guzzlehttp/promises/tests/functionsTest.php
    [116] => /core/scripts/php/vendor/guzzlehttp/psr7/.gitignore
    [117] => /core/scripts/php/vendor/guzzlehttp/psr7/.travis.yml
    [118] => /core/scripts/php/vendor/guzzlehttp/psr7/CHANGELOG.md
    [119] => /core/scripts/php/vendor/guzzlehttp/psr7/LICENSE
    [120] => /core/scripts/php/vendor/guzzlehttp/psr7/Makefile
    [121] => /core/scripts/php/vendor/guzzlehttp/psr7/README.md
    [122] => /core/scripts/php/vendor/guzzlehttp/psr7/composer.json
    [123] => /core/scripts/php/vendor/guzzlehttp/psr7/phpunit.xml.dist
    [124] => /core/scripts/php/vendor/guzzlehttp/psr7/src/AppendStream.php
    [125] => /core/scripts/php/vendor/guzzlehttp/psr7/src/BufferStream.php
    [126] => /core/scripts/php/vendor/guzzlehttp/psr7/src/CachingStream.php
    [127] => /core/scripts/php/vendor/guzzlehttp/psr7/src/DroppingStream.php
    [128] => /core/scripts/php/vendor/guzzlehttp/psr7/src/FnStream.php
    [129] => /core/scripts/php/vendor/guzzlehttp/psr7/src/InflateStream.php
    [130] => /core/scripts/php/vendor/guzzlehttp/psr7/src/LazyOpenStream.php
    [131] => /core/scripts/php/vendor/guzzlehttp/psr7/src/LimitStream.php
    [132] => /core/scripts/php/vendor/guzzlehttp/psr7/src/MessageTrait.php
    [133] => /core/scripts/php/vendor/guzzlehttp/psr7/src/MultipartStream.php
    [134] => /core/scripts/php/vendor/guzzlehttp/psr7/src/NoSeekStream.php
    [135] => /core/scripts/php/vendor/guzzlehttp/psr7/src/PumpStream.php
    [136] => /core/scripts/php/vendor/guzzlehttp/psr7/src/Request.php
    [137] => /core/scripts/php/vendor/guzzlehttp/psr7/src/Response.php
    [138] => /core/scripts/php/vendor/guzzlehttp/psr7/src/ServerRequest.php
    [139] => /core/scripts/php/vendor/guzzlehttp/psr7/src/Stream.php
    [140] => /core/scripts/php/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php
    [141] => /core/scripts/php/vendor/guzzlehttp/psr7/src/StreamWrapper.php
    [142] => /core/scripts/php/vendor/guzzlehttp/psr7/src/UploadedFile.php
    [143] => /core/scripts/php/vendor/guzzlehttp/psr7/src/Uri.php
    [144] => /core/scripts/php/vendor/guzzlehttp/psr7/src/functions.php
    [145] => /core/scripts/php/vendor/guzzlehttp/psr7/src/functions_include.php
    [146] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/AppendStreamTest.php
    [147] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php
    [148] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php
    [149] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php
    [150] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/FnStreamTest.php
    [151] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/FunctionsTest.php
    [152] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php
    [153] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php
    [154] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php
    [155] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php
    [156] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php
    [157] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php
    [158] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/RequestTest.php
    [159] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/ResponseTest.php
    [160] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/ServerRequestTest.php
    [161] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php
    [162] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/StreamTest.php
    [163] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php
    [164] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/UploadedFileTest.php
    [165] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/UriTest.php
    [166] => /core/scripts/php/vendor/guzzlehttp/psr7/tests/bootstrap.php
    [167] => /core/scripts/php/vendor/psr/http-message/CHANGELOG.md
    [168] => /core/scripts/php/vendor/psr/http-message/LICENSE
    [169] => /core/scripts/php/vendor/psr/http-message/README.md
    [170] => /core/scripts/php/vendor/psr/http-message/composer.json
    [171] => /core/scripts/php/vendor/psr/http-message/src/MessageInterface.php
    [172] => /core/scripts/php/vendor/psr/http-message/src/RequestInterface.php
    [173] => /core/scripts/php/vendor/psr/http-message/src/ResponseInterface.php
    [174] => /core/scripts/php/vendor/psr/http-message/src/ServerRequestInterface.php
    [175] => /core/scripts/php/vendor/psr/http-message/src/StreamInterface.php
    [176] => /core/scripts/php/vendor/psr/http-message/src/UploadedFileInterface.php
    [177] => /core/scripts/php/vendor/psr/http-message/src/UriInterface.php
    [178] => /core/scripts/python/login.py
    [179] => /core/scripts/recipient/search.go
    [180] => /core/scripts/recipient/search.php
    [181] => /core/scripts/recipient/search.rb
    [182] => /core/scripts/recipient/search.sh
    [184] => /core/scripts/responses/recipients/response-success.json
    [185] => /core/scripts/responses/recipients/response-success.xml
    [193] => /core/scripts/responses/shares/list-all-shares-failure.xml
    [194] => /core/scripts/responses/shares/list-all-shares-success.xml
)

@settermjd @phil-davis @voroyam @phil-davis your issue: https://github.com/owncloud/docs/issues/758 (Invalid code in MyStorage.php) matches one of the orphanded files found, array item [4]...

mmattel commented 5 years ago

Some of the orpans at /core/scripts/responses/ are covered by PR: https://github.com/owncloud/docs/pull/789

Update

789 is now merged, result list above and below updated

mmattel commented 5 years ago

I did an extension of the script to match which output from above was used in the old documentation. This means we know that those files were valid as they have been used and we know in which directory to look at in old docs. To reduce output of multiple occurrences I only print the directory. It is now relatively easy to identify valid old doc files for the particular script and see if it needs a change in this documention.

Note: I only check for a filename match, not restricted to a manual.

Extended code (appended to the code above)

$old_docs = "../old_doc";
$exclude_path_components = "[examples|\_old\_shared\_assets|\_shared\_assets|\.git]"; # regex

echo "\n";
echo "grep for found matches in: $old_docs" . "\n";
foreach($lost_link as $path) {
  $to_print = "";
  # get only the filename for grep 
  $file_name = \basename($path);
  $cmd = "grep -rl " . "'" . "$file_name" . "' " . $old_docs ;
  $subject = \trim(\shell_exec($cmd)); # string
  if (!empty($subject)) {
    $line = \explode("\n", $subject);
    # there can be more than one match
    foreach($line as $item) {
      $path_parts = \pathinfo($item);
      $path_found = $path_parts['dirname'];
      # exclude specific paths
      if(!\preg_match($exclude_path_components, $path_found)) {
        $to_print = $to_print . "$path_found" . "\n";
      }
    }
  }
  # output only if there is a result found
  if (!empty($to_print)) {
    $to_print = "\n" . "$path" . "\n" . $to_print;
    # remove double occurences
    $double = \explode("\n", $to_print);
    $double = \array_unique($double);
    $to_print = \implode("\n", $double);
    echo "$to_print" . "\n";
  }
}

Result

grep for found matches in: ../old_doc

/app/storage-backend/OCA/MyStorageApp/Backend/MyStorageBackend.php
../old_doc/developer_manual/app/advanced

/app/storage-backend/OCA/MyStorageApp/Storage/MyStorage.php
../old_doc/developer_manual/app/advanced

/core/scripts/php/composer.json
../old_doc/developer_manual/app/tutorial

/core/scripts/php/vendor/autoload.php
../old_doc/developer_manual/core

/core/scripts/php/vendor/composer/LICENSE
../old_doc
../old_doc/admin_manual/appliance

/core/scripts/php/vendor/guzzlehttp/guzzle/CHANGELOG.md
../old_doc/admin_manual

/core/scripts/php/vendor/guzzlehttp/guzzle/LICENSE
../old_doc
../old_doc/admin_manual/appliance

/core/scripts/php/vendor/guzzlehttp/guzzle/README.md
../old_doc/developer_manual/app/fundamentals

/core/scripts/php/vendor/guzzlehttp/guzzle/composer.json
../old_doc/developer_manual/app/tutorial

/core/scripts/php/vendor/guzzlehttp/guzzle/src/functions.php
../old_doc/admin_manual

/core/scripts/php/vendor/guzzlehttp/promises/CHANGELOG.md
../old_doc/admin_manual

/core/scripts/php/vendor/guzzlehttp/promises/LICENSE
../old_doc
../old_doc/admin_manual/appliance

/core/scripts/php/vendor/guzzlehttp/promises/Makefile
../old_doc
../old_doc/admin_manual
../old_doc/developer_manual
../old_doc/user_manual

/core/scripts/php/vendor/guzzlehttp/promises/README.md
../old_doc/developer_manual/app/fundamentals

/core/scripts/php/vendor/guzzlehttp/promises/composer.json
../old_doc/developer_manual/app/tutorial

/core/scripts/php/vendor/guzzlehttp/promises/src/functions.php
../old_doc/admin_manual

/core/scripts/php/vendor/guzzlehttp/promises/tests/bootstrap.php
../old_doc/developer_manual/app/fundamentals
../old_doc/developer_manual/core

/core/scripts/php/vendor/guzzlehttp/psr7/CHANGELOG.md
../old_doc/admin_manual

/core/scripts/php/vendor/guzzlehttp/psr7/LICENSE
../old_doc
../old_doc/admin_manual/appliance

/core/scripts/php/vendor/guzzlehttp/psr7/Makefile
../old_doc
../old_doc/admin_manual
../old_doc/developer_manual
../old_doc/user_manual

/core/scripts/php/vendor/guzzlehttp/psr7/README.md
../old_doc/developer_manual/app/fundamentals

/core/scripts/php/vendor/guzzlehttp/psr7/composer.json
../old_doc/developer_manual/app/tutorial

/core/scripts/php/vendor/guzzlehttp/psr7/src/functions.php
../old_doc/admin_manual

/core/scripts/php/vendor/guzzlehttp/psr7/tests/bootstrap.php
../old_doc/developer_manual/app/fundamentals
../old_doc/developer_manual/core

/core/scripts/php/vendor/psr/http-message/CHANGELOG.md
../old_doc/admin_manual

/core/scripts/php/vendor/psr/http-message/LICENSE
../old_doc
../old_doc/admin_manual/appliance

/core/scripts/php/vendor/psr/http-message/README.md
../old_doc/developer_manual/app/fundamentals

/core/scripts/php/vendor/psr/http-message/composer.json
../old_doc/developer_manual/app/tutorial

/core/scripts/recipient/search.php
../old_doc/admin_manual/configuration/server

/core/scripts/responses/recipients/response-success.json
../old_doc/developer_manual/core
settermjd commented 5 years ago

@mmattel, is this now complete?

mmattel commented 5 years ago

Yes it is. If we fix those once and rerun the script(s) above, it will (should) show the following: