Giter Club home page Giter Club logo

ansible-docgen's People

Contributors

thedavidwhiteside avatar ymil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-docgen's Issues

Playbook parsing is BROKEN. It only works with roles.

Expected playbook format:

TESTING ONLY -


  • hosts: everything/linux
    tasks:
    • shell: grep test /etc/passwd

Currently it does not parse a playbook because it expects a list, It
should infact expect a dictionary with ["tasks"] being a list.

Tasks inside blocks/rescue/always are not added to the generated documentation

Hi @starboarder2001 , @nickpack

Found ansible-docgen to be a great tool to document my roles and playbooks. Thanks for building it !

I see that tasks inside ansible block are not added to the documentation. Provided below is a sample playbook and corresponding documentation :

Playbook

# Author: ksatchit
# Description: ansible-docgen issues with block


- hosts: localhost

  tasks:

    - name: First task in the playbook
      shell: echo "PRINT TASK1"

    - block:
        - name: Second task in the playbook, first in the do block
          shell: echo "PRINT TASK2"

      rescue:
        - name: Third task in playbook, first in the rescue block
          shell: echo "PRINT TASK3"

      always:
        - name: Fourth task in playbook, first in the always block
          shell: echo "PRINT TASK4"

README.md

## Playbook: [sampletest.yml](sampletest.yml)
> **Author:** ksatchit

> **Description:** ansible-docgen issues with block

> **Task:** First task in the playbook

TypeError: load() missing 1 required positional argument: 'Loader'

The error TypeError: load() missing 1 required positional argument: 'Loader' comes up at running the docgen on ansible directory (playbook dir or role dir).

Context

Dockerfile:

FROM python:3.9-slim
RUN pip install ansible-docgen
WORKDIR /app

Run docker image:

docker run -ti --rm -v $PWD:/app ansible-docgen:latest ansible-docgen -p ansible-playbooks/roles/myrole

Error stacktrace:

Traceback (most recent call last):
  File "/usr/local/bin/ansible-docgen", line 7, in <module>
    cli.run()
  File "/usr/local/lib/python3.9/site-packages/ansibledocgen/cli.py", line 37, in run
    self.dirparser = DirParser(project)
  File "/usr/local/lib/python3.9/site-packages/ansibledocgen/parser/dir.py", line 20, in __init__
    self.playbookparser.parse_playbooks()
  File "/usr/local/lib/python3.9/site-packages/ansibledocgen/parser/playbook.py", line 20, in parse_playbooks
    self.parse_playbook(playbook)
  File "/usr/local/lib/python3.9/site-packages/ansibledocgen/parser/playbook.py", line 52, in parse_playbook
    yamldata = yaml.load(data)
TypeError: load() missing 1 required positional argument: 'Loader'

How to reproduce?

docker build . -t ansible-docgen:latest
docker run -ti --rm -v $PWD:/app ansible-docgen:latest ansible-docgen -p ansible-playbooks/roles/myrole

Need an option to generate documentation with filename of choice

Currently, ansible-docgen always creates a README.md as the default markdown doc. User should be given a choice to specify a filename of his choice. Something like the below :

ansible-docgen -f playbook_info

  ...generates playbook_info.md

In my case, the README is a file containing info about the general purpose of a set of playbooks OR roles in a folder. While I would love to have the doc telling me about the specifics/summary of each playbook/role , I wouldn't want it to replace the README.md

Of course, it could be argued that the original README can be moved to a different filename - but somehow I would like to have original README as the readme a user should be directed to.

YAML Parser seems unhappy about vault encrypted variables

Traceback (most recent call last):
  File "/home/tsiakalt/.local/bin/ansible-docgen", line 7, in <module>
    cli.run()
  File "/home/tsiakalt/.local/lib/python3.7/site-packages/ansibledocgen/cli.py", line 37, in run
    self.dirparser = DirParser(project)
  File "/home/tsiakalt/.local/lib/python3.7/site-packages/ansibledocgen/parser/dir.py", line 20, in __init__
    self.playbookparser.parse_playbooks()
  File "/home/tsiakalt/.local/lib/python3.7/site-packages/ansibledocgen/parser/playbook.py", line 20, in parse_playbooks
    self.parse_playbook(playbook)
  File "/home/tsiakalt/.local/lib/python3.7/site-packages/ansibledocgen/parser/playbook.py", line 52, in parse_playbook
    yamldata = yaml.load(data)
  File "/usr/local/lib/python3.7/dist-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 143, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/local/lib/python3.7/dist-packages/yaml/constructor.py", line 429, in construct_undefined
    node.start_mark)
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!vault'
  in "<unicode string>", line 32, column 19:
            password: !vault |

Empty .yml files break things

Incorrectly formatted .yml files cause this error:
The original error was:
$ansible-docgen
Traceback (most recent call last):
File "/usr/local/bin/ansible-docgen", line 7, in
cli.run()
File "/Library/Python/2.7/site-packages/ansibledocgen/cli.py", line 37, in run
self.dirparser = DirParser(project)
File "/Library/Python/2.7/site-packages/ansibledocgen/parser/dir.py",
line 15, in init
self.roleparser = RoleParser(self.ansiblecfg.get_role_paths())
File "/Library/Python/2.7/site-packages/ansibledocgen/parser/role.py",
line 18, in init
self.parse_main_tasks()
File "/Library/Python/2.7/site-packages/ansibledocgen/parser/role.py",
line 39, in parse_main_tasks
self.playbookparser.parse_playbooks()
File "/Library/Python/2.7/site-packages/ansibledocgen/parser/playbook.py",
line 20, in parse_playbooks
self.parse_playbook(playbook)
File "/Library/Python/2.7/site-packages/ansibledocgen/parser/playbook.py",
line 52, in parse_playbook
for task in yaml.load(data):
TypeError: 'NoneType' object is not iterable

Project 3 integration test generates invalid test/integration/project3/README.md

It only knows about the otherroles path, and not the roles path. It then parses the roles path expecting playbooks.

  1. Need to improve ability to detect role paths and exclude them without them being defined.
  2. Need to see how Ansible handles this itself. What does Ansible do if you define an alternate role path, yet still have a standard "roles" directory.

UTF-8 non-ASCII chars

Traceback (most recent call last):
File "/bin/ansible-docgen", line 7, in
cli.run()
File "/usr/lib/python2.7/site-packages/ansibledocgen/cli.py", line 44, in run
self.formatter.write_files()
File "/usr/lib/python2.7/site-packages/ansibledocgen/formatter/markup.py", line 115, in write_files
p.write("%s" % line)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 34: ordinal not in range(128)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.