Skip to content

AttributeError: 'DirectiveAdapter' object has no attribute '_hcl_def'

I'm attempting to use sphinx, and sphinx-terraform, for the first time ever. I've set up my project, and installed sphinx-terraform. When I attempt to sphinx-build -b html ... I get the error below. I tried running it again with a completely empty terraform directory, save for an empty main.tf file, and still got the error.

Exception occurred:
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx_terraform/markup.py", line 281, in transform_content
    hcl_def = self._hcl_def
AttributeError: 'DirectiveAdapter' object has no attribute '_hcl_def'

Here's the full stack trace:

# Sphinx version: 5.2.3
# Python version: 3.10.7 (CPython)
# Docutils version: 0.19 
# Jinja2 version: 3.1.2
# Last messages:
#   Running Sphinx v5.2.3
#   building [mo]: targets for 0 po files that are out of date
#   building [html]: targets for 1 source files that are out of date
#   updating environment:
#   [new config]
#   1 added, 0 changed, 0 removed
#   reading sources... [100%] index
# Loaded extensions:
#   sphinx.ext.mathjax (5.2.3) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/alabaster/__init__.py
#   sphinx_terraform (0.2) from /Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx_terraform/__init__.py
Traceback (most recent call last):
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/cmd/build.py", line 279, in build_main
    app.build(args.force_all, filenames)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/application.py", line 350, in build
    self.builder.build_update()
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 302, in build_update
    self.build(to_build,
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 318, in build
    updated_docnames = set(self.read())
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 425, in read
    self._read_serial(docnames)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 446, in _read_serial
    self.read_doc(docname)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 502, in read_doc
    publisher.publish()
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/core.py", line 224, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/io.py", line 104, in read
    self.parse()
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/parsers.py", line 78, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
    self.explicit_list(blank_finish)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2382, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2660, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
    return method(self, expmatch)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
    return self.run_directive(
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
    result = directive_instance.run()
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/domains/__init__.py", line 281, in run
    return super().run()
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx/directives/__init__.py", line 263, in run
    self.transform_content(contentnode)
  File "/Users/daraul/Development/password-manager/venv/lib/python3.10/site-packages/sphinx_terraform/markup.py", line 281, in transform_content
    hcl_def = self._hcl_def
AttributeError: 'DirectiveAdapter' object has no attribute '_hcl_def'