Add filter for skipping files earlier in the pipeline than 'wp_parser_pre_import_file'
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- php
- Lĩnh vực
- documentation
Hướng nghiên cứu
Bắt đầu tại WP_Parser\get_wp_files() và so sánh luồng phát hiện tệp của hàm này với bộ lọc wp_parser_pre_import_file hiện có trong WP_Parser\Importer::import_file(). Thêm bộ lọc ở giai đoạn sớm hơn với các đối số tệp và thư mục được đề xuất, đồng thời xác nhận rằng các tệp bị từ chối tại đó không được phân tích cú pháp hoặc nhập vào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
\\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;
}
- Ngôn ngữ chính
- PHP
- Star
- 239
- Fork
- 81
- Merge trung bình
- 16 giờ 29 phút
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của WordPress/phpdoc-parser
-
Include constants in exports Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
WordPress/phpdoc-parser#269 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
WordPress/phpdoc-parser#268 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
WordPress/phpdoc-parser#254 ·
-
Compatibility updates required Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
WordPress/phpdoc-parser#246 · 9 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
WordPress/phpdoc-parser#235 · 1 bình luận ·
Tất cả issue của WordPress/phpdoc-parser
Issue tương tự
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Перевод устарел
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
az-digital/az_quickstart#6047 ·
-
Error when saving email Đang mởbug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100