Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jinja error when trying to build documentation for a collection #141

Closed
evgeni opened this issue Jul 21, 2020 · 7 comments · Fixed by #142
Closed

Jinja error when trying to build documentation for a collection #141

evgeni opened this issue Jul 21, 2020 · 7 comments · Fixed by #142

Comments

@evgeni
Copy link

evgeni commented Jul 21, 2020

(venv) evgeni@yatsu /tmp % ansible-galaxy collection install theforeman.foreman
Process install dependency map
Starting collection install process
Installing 'theforeman.foreman:1.0.1' to '/home/evgeni/.ansible/collections/ansible_collections/theforeman/foreman'

(venv) evgeni@yatsu /tmp % antsibull-docs collection --use-current --dest-dir lol theforeman.foreman
Traceback (most recent call last):
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/bin/antsibull-docs", line 8, in <module>
    sys.exit(main())
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/cli/antsibull_docs.py", line 272, in main
    return run(sys.argv)
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/cli/antsibull_docs.py", line 253, in run
    return ARGS_MAP[args.command]()
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/cli/doc_commands/collection.py", line 43, in generate_docs
    return generate_current_docs()
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/cli/doc_commands/collection.py", line 23, in generate_current_docs
    generate_docs_for_all_collections(
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/cli/doc_commands/stable.py", line 290, in generate_docs_for_all_collections
    asyncio_run(output_all_plugin_rst(collection_info, plugin_info,
  File "/usr/lib64/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/write_docs.py", line 117, in output_all_plugin_rst
    plugin_tmpl = env.get_template('plugin.rst.j2')
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/jinja2/environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/jinja2/environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/jinja2/loaders.py", line 127, in load
    code = environment.compile(source, name, filename)
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/jinja2/environment.py", line 638, in compile
    self.handle_exception(source=source_hint)
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/home/evgeni/Devel/theforeman/foreman-ansible-modules/venv/lib64/python3.8/site-packages/antsibull/data/docsite/plugin.rst.j2", line 49, in template
    {% plugin_name.rsplit('.', 1)[-1] %} even without specifying the ``collection:`` keyword.
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'plugin_name'. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.

Removing the offending line ( {% plugin_name.rsplit('.', 1)[-1] %} even without specifying the ``collection:`` keyword.) makes the error go away, but the destination folder remains empty :(

@evgeni
Copy link
Author

evgeni commented Jul 21, 2020

The same also happens when I pass an invalid/nonexisting collection name.

@evgeni
Copy link
Author

evgeni commented Jul 21, 2020

@felixfontein does the collection need to be installed as a Python egg (like antsibull can do it) or does ~/.ansible/collections suffice?

@felixfontein
Copy link
Collaborator

felixfontein commented Jul 21, 2020

@evgeni the collection needs to be installed with ansible-galaxy collection install, or in any other form a ansible collection can be installed (i.e. it needs to be copied somewhere so that ansible will find it).

The stack trace in this issue is fixed in #142. With that fix, your command line works for me:

$ find lol/
lol/
lol/collections
lol/collections/theforeman
lol/collections/theforeman/foreman
lol/collections/theforeman/foreman/foreman_callback.rst
lol/collections/theforeman/foreman/smart_class_parameter_module.rst
lol/collections/theforeman/foreman/scap_tailoring_file_module.rst
lol/collections/theforeman/foreman/config_group_module.rst
lol/collections/theforeman/foreman/repository_set_module.rst
lol/collections/theforeman/foreman/hardware_model_module.rst
lol/collections/theforeman/foreman/location_module.rst
lol/collections/theforeman/foreman/puppet_environment_module.rst
lol/collections/theforeman/foreman/content_upload_module.rst
lol/collections/theforeman/foreman/host_power_module.rst
lol/collections/theforeman/foreman/repository_module.rst
lol/collections/theforeman/foreman/index.rst
lol/collections/theforeman/foreman/domain_module.rst
lol/collections/theforeman/foreman/usergroup_module.rst
lol/collections/theforeman/foreman/global_parameter_module.rst
lol/collections/theforeman/foreman/redhat_manifest_module.rst
lol/collections/theforeman/foreman/architecture_module.rst
lol/collections/theforeman/foreman/host_collection_module.rst
lol/collections/theforeman/foreman/operatingsystem_module.rst
lol/collections/theforeman/foreman/provisioning_template_module.rst
lol/collections/theforeman/foreman/sync_plan_module.rst
lol/collections/theforeman/foreman/content_credential_module.rst
lol/collections/theforeman/foreman/compute_attribute_module.rst
lol/collections/theforeman/foreman/foreman_inventory.rst
lol/collections/theforeman/foreman/scap_content_module.rst
lol/collections/theforeman/foreman/content_view_version_module.rst
lol/collections/theforeman/foreman/resource_info_module.rst
lol/collections/theforeman/foreman/role_module.rst
lol/collections/theforeman/foreman/realm_module.rst
lol/collections/theforeman/foreman/content_view_filter_module.rst
lol/collections/theforeman/foreman/organization_module.rst
lol/collections/theforeman/foreman/external_usergroup_module.rst
lol/collections/theforeman/foreman/scc_account_module.rst
lol/collections/theforeman/foreman/setting_module.rst
lol/collections/theforeman/foreman/partition_table_module.rst
lol/collections/theforeman/foreman/compute_profile_module.rst
lol/collections/theforeman/foreman/job_template_module.rst
lol/collections/theforeman/foreman/repository_sync_module.rst
lol/collections/theforeman/foreman/auth_source_ldap_module.rst
lol/collections/theforeman/foreman/os_default_template_module.rst
lol/collections/theforeman/foreman/compute_resource_module.rst
lol/collections/theforeman/foreman/image_module.rst
lol/collections/theforeman/foreman/hostgroup_module.rst
lol/collections/theforeman/foreman/content_view_module.rst
lol/collections/theforeman/foreman/snapshot_module.rst
lol/collections/theforeman/foreman/bookmark_module.rst
lol/collections/theforeman/foreman/scc_product_module.rst
lol/collections/theforeman/foreman/subscription_manifest_module.rst
lol/collections/theforeman/foreman/product_module.rst
lol/collections/theforeman/foreman/subnet_module.rst
lol/collections/theforeman/foreman/host_module.rst
lol/collections/theforeman/foreman/templates_import_module.rst
lol/collections/theforeman/foreman/installation_medium_module.rst
lol/collections/theforeman/foreman/activation_key_module.rst
lol/collections/theforeman/foreman/user_module.rst
lol/collections/theforeman/foreman/lifecycle_environment_module.rst

@evgeni
Copy link
Author

evgeni commented Jul 21, 2020

Thanks. I have it installed with "galaxy collection install". Will try again.

@evgeni
Copy link
Author

evgeni commented Jul 22, 2020

@felixfontein ah, I need ansible(-base) 2.10 as that's the first one having collection list support in ansible-doc. Got it, thanks!

@felixfontein
Copy link
Collaborator

felixfontein commented Jul 22, 2020

@evgeni ah, so you used 2.9 before and it didn't work, and with 2.10 (or devel) it now works? Good to hear (that it now works)!

@evgeni
Copy link
Author

evgeni commented Jul 22, 2020

Yeah, before I had 2.9, now 2.10b1.

Current progress: theforeman/foreman-ansible-modules#895 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants