Add filter for skipping files earlier in the pipeline than 'wp_parser_pre_import_file'
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- php
調査の方向性
WP_Parser\get_wp_files() から始め、そのファイル検出フローを WP_Parser\Importer::import_file() にある既存の wp_parser_pre_import_file フィルターと比較します。提案されているファイル引数とディレクトリ引数を指定して、より早い段階のフィルターを追加し、そこで拒否されたファイルが解析もインポートもされないことを確認します。
索引モデルが issue の本文から書いたものです。
説明
\\WP_Parser\Importer::import_file() provides the wp_parser_pre_import_file filter to skip importing a particular file.
It would improve efficiency if there were a similar filter earlier in the pipeline, e.g., in \\WP_Parser\get_wp_files(). For example,
function get_wp_files( $directory ) {
$iterableFiles = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator( $directory )
);
$files = array();
try {
foreach ( $iterableFiles as $file ) {
if ( 'php' !== $file->getExtension() ) {
continue;
}
if ( ! apply_filters( 'wp_parser_pre_get_wp_file', true, $file->getPathname(), $directory ) ) {
continue;
}
$files[] = $file->getPathname();
}
} catch ( \UnexpectedValueException $exc ) {
return new \WP_Error(
'unexpected_value_exception',
sprintf( 'Directory [%s] contained a directory we can not recurse into', $directory )
);
}
return $files;
}
I use this plugin to produce developer documentation for plugins/themes I create for clients, and currently hook into wp_parser_pre_import_file to skip importing anything in tests/ or vendor/ sub-dirs of a plugin/theme. Having the proposed wp_parser_pre_get_wp_file hook would allow avoiding the overhead of parsing all those files, only to skip them later in the pipeline.
Here is an example of a func I would hook into the proposed filter, to show why the proposed filter takes the additional $directory param that wp_parser_pre_import_file does not:
add_filter( 'wp_parser_pre_get_wp_file', 'shc_wp_parser_skip_files', 10, 3 );
function shc_wp_parser_skip_files( $default, $file, $directory ) {
$file = str_replace( $directory . DIRECTORY_SEPARATOR, '', $file );
$paths = explode( DIRECTORY_SEPARATOR, $file );
if ( in_array( $paths[1], array( 'tests', 'vendor' ) ) ) {
return false;
}
return $default;
}
- 主要言語
- PHP
- スター
- 239
- フォーク
- 81
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 5
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
WordPress/phpdoc-parser のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
WordPress/phpdoc-parser#269 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
WordPress/phpdoc-parser#268 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
WordPress/phpdoc-parser#254 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
WordPress/phpdoc-parser#246 · コメント 9 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
WordPress/phpdoc-parser#235 · コメント 1 件 ·
WordPress/phpdoc-parser の issue をすべて見る
似ている issue
-
Update the one-click "GTM4WP" Delay JS exclusion so that it also works with a custom data layer nameオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Feature]: Remove Kanboard Discourse forum link from README.md and CONTRIBUTING.md, or moderate itオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
solana-foundation/pay-kit#341 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cline/cline#14560 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100