从另一个Perl 6文件访问POD

时间:2018-06-22 14:58:52

标签: perl6 pod6

Perl 6 POD documentation包含有关使用$=pod访问当前文件的POD文档的部分。没有有关访问另一个文件的POD文档的信息。

如何在不更改当前文件的$=pod的情况下访问另一个文件的POD结构?

3 个答案:

答案 0 :(得分:4)

您现在可以使用Pod::Load进行此操作。来自the README in the examples directory

ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "companies" does not exist
LINE 8:                WHERE a.attrelid = '"companies"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"companies"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `async_exec'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:579:in `block (2 levels) in log'
/usr/local/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:578:in `block in log'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:569:in `log'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:749:in `column_definitions'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:113:in `columns'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/schema_cache.rb:69:in `columns'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/connection_adapters/schema_cache.rb:75:in `columns_hash'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:466:in `load_schema!'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/attributes.rb:234:in `load_schema!'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:459:in `block in load_schema'
/usr/local/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:456:in `load_schema'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:346:in `attribute_types'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/attribute_methods.rb:230:in `has_attribute?'
/usr/local/bundle/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:55:in `new'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/decorator/new_constructor.rb:9:in `new'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/decorator.rb:14:in `send'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/decorator.rb:10:in `method_missing'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/decorator/invocation_tracker.rb:11:in `method_missing'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/decorator.rb:14:in `send'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/decorator.rb:10:in `method_missing'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/configuration.rb:19:in `block in initialize'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/attribute_assigner.rb:48:in `instance_exec'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/attribute_assigner.rb:48:in `build_class_instance'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/attribute_assigner.rb:13:in `object'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/evaluation.rb:13:in `object'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/strategy/create.rb:9:in `result'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/factory.rb:43:in `run'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/notifications.rb:170:in `instrument'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/factory_runner.rb:28:in `run'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
/builds/MyGroup/MyApp/spec/factories/users.rb:4:in `block in <main>'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/syntax/default.rb:49:in `instance_eval'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/syntax/default.rb:49:in `run'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/syntax/default.rb:7:in `define'
/builds/MyGroup/MyApp/spec/factories/users.rb:2:in `<main>'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `block in load'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `load'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/find_definitions.rb:20:in `block (2 levels) in find_definitions'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/find_definitions.rb:19:in `each'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/find_definitions.rb:19:in `block in find_definitions'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/find_definitions.rb:15:in `each'
/usr/local/bundle/gems/factory_bot-4.11.1/lib/factory_bot/find_definitions.rb:15:in `find_definitions'
/usr/local/bundle/gems/factory_bot_rails-4.11.1/lib/factory_bot_rails/railtie.rb:21:in `block in <class:Railtie>'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `each'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
/usr/local/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/local/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/local/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/local/lib/ruby/2.5.0/tsort.rb:347:in `each'
/usr/local/lib/ruby/2.5.0/tsort.rb:347:in `call'
/usr/local/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/local/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
/usr/local/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
/builds/MyGroup/MyApp/config/environment.rb:5:in `<main>'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'
/usr/local/bundle/gems/railties-5.2.0/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
/usr/local/bundle/gems/bugsnag-6.8.0/lib/bugsnag/integrations/rake.rb:18:in `execute_with_bugsnag'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:237:in `block in invoke_prerequisites'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:235:in `each'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:235:in `invoke_prerequisites'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:212:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:83:in `block in run'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.1/lib/rake/application.rb:80:in `run'
/usr/local/bundle/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:23:in `load'
/usr/local/bundle/bin/rake:23:in `<top (required)>'

请注意,Pod6文件必须“干净”,即,不要使用通常不可用的任何外部模块,否则可能会失败。

答案 1 :(得分:2)

也许有人知道一种干净的方法,在这种情况下,除非有人确认它有效,否则我可能会删除这个弱小的 unested 排序方式。 em>和大致共识是值得离开这里。

我怀疑你必须绕着桑树丛。

类似以下内容。 (未经测试。)

char *c = fgets(input, 3, stdin);
if (c == NULL) { // EOF reached
    break;
}
if (input[strlen(input)-1] == '\n') {
    input[strlen(input)-1] = '\0';
} else {
    int c;
    while ((c = getchar()) != '\n' && c != EOF) {
    }
}

保存在unit class Pod::To::DotPerl; method render ($pod) { print $pod.perl } 中,然后与lib/Pod/To/DotPerl.pm6一起安装(未经测试):

zef

请参见my previous answer的末尾,以了解发生的事情。

答案 2 :(得分:1)

我已经在Module::Pod(即将发布)中创建了与文件系统无关的解决方案,网址为git@github.com:dmaestro / Module-Pod.git

use Module::Pod;

# Get all Pod::Block::* objects in the module, from its own $=pod
my @pod = pod-from-module(<My::Module>);

优点:

  • 没有直接逃逸的文件代码(即使在Module :: Pod中也是如此)
  • 使用CompUnit :: Repository和kin定位模块
  • 可以在有或没有use的情况下将模块用于代码中的其他目的
  • 如果模块已经加载,则可以使用其类型对象进行调用

缺点:

  • 模块直接使用nqp:方法,如Pod :: Convenience(也许不是一个骗局?)
  • 无法从* .pod文件中检索pod

旨在用于Pod6检查测试等