Giter VIP home page Giter VIP logo

doc_to_readme's Introduction

Automated (Python) Module Documentation in README

What's this?

Automated docstring extraction and creation/update of documentation (of python modules) in README File.

Why?

Because it's nice :-)

How?

doc_to_md.py loops through all Python files in the Repository and extracts the function calls + the corresponding short description from the docstrings. These are added to a dictionary and afterwards converted to a Markdown Table. Finally, the section Functions & Classes is appended / updated in the README File.

There are several options how to use it:
a) Python Package
b) CI Pipeline

a) install & use Python Package

Available on PyPI

pip install doc-to-readme
  • Use within Python
import doc_to_md.doc_to_md as dtm

dtm.update_markdown_file(
    file="README.md",
    root_dir=None,              # Directory used as root for searching modules, defaults to folder containing README.md
    exclude_modules=None,       # List of modules to be excluded
    specified_modules=None,     # Only these modules will be included
    separate=True               # Create one table per module
)
  • Command Line
python -m doc_to_md.doc_to_md -f "README.md" [-r ROOT_DIR] [-e EXCLUDE_MODULES] [-m SELECTED_MODULES] [--separated]

-r ROOT_DIR             # Directory used as root for searching modules, defaults to folder containing README.md
-e EXCLUDE_MODULES      # List of modules to be excluded
-m SELECTED_MODULES     # Only these modules will be included
--separated             # Create one table per module

b) add to Pipeline (GitHub, GitLab or Bitbucket)

Documentation on how to set up the pipelines to update a file on every push.

Step-by-step guide on how to integrate doc_to_readme in your Repository


Copyright © 2023 by Mirjam Ziselsberger
This code is free to use under the terms of the MIT license.

Functions & Classes

Type Name/Call Description
function loop_through_repo(file: str, root_dir: str = None, exclude_modules: Optional[Tuple[str, ...]] = None, specified_modules: Optional[Tuple[str, ...]] = None) -> None Collect documentation from functions & classes.
function add_summary_to_md(overview_dict: Dict[str, Optional[Union[str, Dict[str, str]]]], markdown: str, separate: bool = True) Add Table with all Functions & Classes to Markdown file.
function update_markdown_file(file: str = "../../README.md", root_dir: str = None, exclude_modules: Optional[Tuple[str, ...]] = ("test", "functions_for_testing", "classes_for_testing", "doc_to_md"), specified_modules: Optional[Tuple[str, ...]] = None, separate: bool = True) Add/update 'Functions & Classes' Section in Markdown file.
function parse_through_file(file: str) -> Dict[str, Dict[str, str]] Parse through file, return dict with classes and functions.
Type Name/Call Description
class LoopThroughRepo None
method (LoopThroughRepo) setUp(self) -> None None
method (LoopThroughRepo) test_loop_through_repo(self) None
method (LoopThroughRepo) test_loop_through_repo_specified_modules(self) None
method (LoopThroughRepo) test_loop_through_repo_exclude_modules(self) None

Created with: doc_to_readme
MIT © 2023 Mirjam Ziselsberger


Last Update: 2024-04-28

doc_to_readme's People

Contributors

ziselsberger avatar

Stargazers

P. Kandolf avatar

Watchers

 avatar

doc_to_readme's Issues

Separate classes/modules in output table

Dear Mrs. Zieselsberger,
Your work is amazing! I would really appreciate it if the output of your tool would be divided into separate sections according to the files/classes where the corresponding function can be found. E.g. like this:

Class 1

method1(...) Description
method2(...) Description

Module 1

function1(..) Description

etc.

Thank you and keep going!

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.