diff --git a/.codeclimate.yml b/.codeclimate.yml index dcf25bd147f..7395ee88e39 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -18,7 +18,6 @@ ratings: - "includes/*" exclude_paths: - "tests/" -- "apigen/" - "sample-data/" - "i18n/" - "includes/api/legacy/" diff --git a/.gitattributes b/.gitattributes index d728da00bed..1b5a2bb019a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,4 @@ /.* export-ignore -apigen* export-ignore CODE_OF_CONDUCT.md export-ignore CHANGELOG.txt export-ignore composer.* export-ignore diff --git a/.gitignore b/.gitignore index 6d673efc6ba..4af7307f91e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,9 +24,6 @@ none # Windows junk Thumbs.db -# ApiGen -/wc-apidocs/ - # Behat/CLI Tests tests/cli/installer tests/cli/composer.phar diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 988a1febcbe..0fd5723b7c4 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -23,7 +23,6 @@ checks: verify_property_names: false filter: excluded_paths: - - apigen/ - sample-data/ - i18n/ - includes/api/legacy/ diff --git a/Gruntfile.js b/Gruntfile.js index 4c3214202ee..4634f1106ea 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -197,7 +197,6 @@ module.exports = function( grunt ) { options: { potFilename: 'woocommerce.pot', exclude: [ - 'apigen/.*', 'vendor/.*', 'tests/.*', 'tmp/.*' @@ -230,7 +229,6 @@ module.exports = function( grunt ) { files: { src: [ '**/*.php', // Include all files - '!apigen/**', // Exclude apigen/ '!includes/libraries/**', // Exclude libraries/ '!node_modules/**', // Exclude node_modules/ '!tests/**', // Exclude tests/ @@ -247,13 +245,6 @@ module.exports = function( grunt ) { stdout: true, stderr: true }, - apidocs: { - command: [ - 'vendor/bin/apigen generate -q', - 'cd apigen', - 'php hook-docs.php' - ].join( '&&' ) - }, e2e_test: { command: 'npm run --silent test:single tests/e2e-tests/' + grunt.option( 'file' ) }, @@ -295,9 +286,6 @@ module.exports = function( grunt ) { // Clean the directory. clean: { - apidocs: { - src: [ 'wc-apidocs' ] - }, blocks: { src: [ '<%= dirs.js %>/blocks', @@ -315,7 +303,6 @@ module.exports = function( grunt ) { dist: { src: [ '**/*.php', // Include all php files. - '!apigen/**', '!includes/api/legacy/**', '!includes/libraries/**', '!node_modules/**', @@ -439,11 +426,6 @@ module.exports = function( grunt ) { 'copy' ]); - grunt.registerTask( 'docs', [ - 'clean:apidocs', - 'shell:apidocs' - ]); - grunt.registerTask( 'contributors', [ 'prompt:contributors', 'shell:contributors' diff --git a/apigen.neon b/apigen.neon deleted file mode 100644 index ea3f1cac40e..00000000000 --- a/apigen.neon +++ /dev/null @@ -1,22 +0,0 @@ -destination: wc-apidocs -templateConfig: apigen/theme-woocommerce/config.neon -extensions: [php] -source: - - woocommerce.php - - includes -exclude: - - includes/libraries/ - - includes/api/legacy/ - - api/legacy/ - - libraries/ -charset: [UTF-8] -main: WC -title: WooCommerce Code Reference -baseUrl: https://docs.woocommerce.com/wc-apidocs/ -templateTheme: default -php: false -sourceCode: true -tree: true -deprecated: true -todo: true -download: false diff --git a/apigen/hook-docs.php b/apigen/hook-docs.php deleted file mode 100644 index 74087e50198..00000000000 --- a/apigen/hook-docs.php +++ /dev/null @@ -1,226 +0,0 @@ -' . $hook . ''; - } - - public static function process_hooks() { - self::$files_to_scan = array(); - - self::$files_to_scan['Template Files'] = self::get_files( '*.php', GLOB_MARK, '../templates/' ); - self::$files_to_scan['Template Functions'] = array( '../includes/wc-template-functions.php', '../includes/wc-template-hooks.php' ); - self::$files_to_scan['Shortcodes'] = self::get_files( '*.php', GLOB_MARK, '../includes/shortcodes/' ); - self::$files_to_scan['Widgets'] = self::get_files( '*.php', GLOB_MARK, '../includes/widgets/' ); - self::$files_to_scan['Data Stores'] = self::get_files( '*.php', GLOB_MARK, '../includes/data-stores' ); - self::$files_to_scan['Core Classes'] = array_merge( - self::get_files( '*.php', GLOB_MARK, '../includes/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/abstracts/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/customizer/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/emails/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/export/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/gateways/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/import/' ), - self::get_files( '*.php', GLOB_MARK, '../includes/shipping/' ) - ); - - self::$files_to_scan = array_filter( self::$files_to_scan ); - - $scanned = array(); - - ob_start(); - - $index = array(); - - foreach ( self::$files_to_scan as $heading => $files ) { - $index[] = '' . $heading . ''; - } - - echo '
'; - echo '

Action and Filter Hook Reference

'; - echo '
-

This is simply a list of action and filter hooks found within WooCommerce files. View the source to see supported params and usage.

-

' . implode( ', ', $index ) . '

-
'; - - foreach ( self::$files_to_scan as $heading => $files ) { - self::$custom_hooks_found = array(); - - foreach ( $files as $f ) { - self::$current_file = basename( $f ); - $tokens = token_get_all( file_get_contents( $f ) ); - $token_type = false; - $current_class = ''; - $current_function = ''; - - if ( in_array( self::$current_file, $scanned ) ) { - continue; - } - - $scanned[] = self::$current_file; - - foreach ( $tokens as $index => $token ) { - if ( is_array( $token ) ) { - $trimmed_token_1 = trim( $token[1] ); - if ( T_CLASS == $token[0] ) { - $token_type = 'class'; - } elseif ( T_FUNCTION == $token[0] ) { - $token_type = 'function'; - } elseif ( 'do_action' === $token[1] ) { - $token_type = 'action'; - } elseif ( 'apply_filters' === $token[1] ) { - $token_type = 'filter'; - } elseif ( $token_type && ! empty( $trimmed_token_1 ) ) { - switch ( $token_type ) { - case 'class' : - $current_class = $token[1]; - break; - case 'function' : - $current_function = $token[1]; - break; - case 'filter' : - case 'action' : - $hook = trim( $token[1], "'" ); - $hook = str_replace( '_FUNCTION_', strtoupper( $current_function ), $hook ); - $hook = str_replace( '_CLASS_', strtoupper( $current_class ), $hook ); - $hook = str_replace( '$this', strtoupper( $current_class ), $hook ); - $hook = str_replace( array( '.', '{', '}', '"', "'", ' ', ')', '(' ), '', $hook ); - $loop = 0; - - // Keep adding to hook until we find a comma or colon - while ( 1 ) { - $loop ++; - $prev_hook = is_string( $tokens[ $index + $loop - 1 ] ) ? $tokens[ $index + $loop - 1 ] : $tokens[ $index + $loop - 1 ][1]; - $next_hook = is_string( $tokens[ $index + $loop ] ) ? $tokens[ $index + $loop ] : $tokens[ $index + $loop ][1]; - - if ( in_array( $next_hook, array( '.', '{', '}', '"', "'", ' ', ')', '(' ) ) ) { - continue; - } - - if ( in_array( $next_hook, array( ',', ';' ) ) ) { - break; - } - - $hook_first = substr( $next_hook, 0, 1 ); - $hook_last = substr( $next_hook, -1, 1 ); - - if ( '{' === $hook_first || '}' === $hook_last || '$' === $hook_first || ')' === $hook_last || '>' === substr( $prev_hook, -1, 1 ) ) { - $next_hook = strtoupper( $next_hook ); - } - - $next_hook = str_replace( array( '.', '{', '}', '"', "'", ' ', ')', '(' ), '', $next_hook ); - - $hook .= $next_hook; - } - - if ( isset( self::$custom_hooks_found[ $hook ] ) ) { - self::$custom_hooks_found[ $hook ]['file'][] = self::$current_file; - } else { - self::$custom_hooks_found[ $hook ] = array( - 'line' => $token[2], - 'class' => $current_class, - 'function' => $current_function, - 'file' => array( self::$current_file ), - 'type' => $token_type, - ); - } - break; - } - $token_type = false; - } - } - } - } - - foreach ( self::$custom_hooks_found as $hook => $details ) { - if ( ! strstr( $hook, 'woocommerce' ) && ! strstr( $hook, 'product' ) && ! strstr( $hook, 'wc_' ) ) { - //unset( self::$custom_hooks_found[ $hook ] ); - } - } - - ksort( self::$custom_hooks_found ); - - if ( ! empty( self::$custom_hooks_found ) ) { - echo '

' . $heading . '

'; - - echo ''; - - foreach ( self::$custom_hooks_found as $hook => $details ) { - echo ' - - - - ' . "\n"; - } - - echo '
HookTypeFile(s)
' . self::get_hook_link( $hook, $details ) . '' . $details['type'] . '' . implode( ', ', array_unique( $details['file'] ) ) . '
'; - } - } - - echo '