sphinx builder that outputs markdown files.

Overview

sphinx-markdown-builder

PyPI PyPI - Downloads PyPI - Python Version GitHub stars Liberapay receiving Liberapay patrons

sphinx builder that outputs markdown files

Please ★ this repo if you found it useful ★ ★ ★

If you want frontmatter support please use sphinx-jekyll-builder

Built by Silicon Hills LLC

index

Silicon Hills offers premium Node and React develpoment and support services. Get in touch at nuevesolutions.com.

Recommended Projects

Features

  • Generates markdown

Installation

pip3 install sphinx-markdown-builder

Dependencies

Usage

Build markdown files with Makefile

make markdown

Build markdown files with sphinx-build command

cd docs
sphinx-build -M markdown ./ build

Support

Submit an issue

Screenshots

Contribute a screenshot

Contributing

Review the guidelines for contributing

License

MIT License

Jam Risser © 2018

Changelog

Review the changelog

Credits

Support on Liberapay

A ridiculous amount of coffee was consumed in the process of building this project.

Add some fuel if you'd like to keep me going!

Liberapay receiving Liberapay patrons

Comments
  • Add table support

    Add table support

    I have already implemented table support, but I'm am not sure how well it works across different setups. Feedback would be much appreciated.

    I am keeping track of where I am in the table to hopefully make it easy to add support for nested tables in the future. Keeping track of where you are is a simple pop/push operation. Push (append) the current node to the node type array when the node is entered, and pop it off the node type array when the node is departed.

        def visit_table(self, node):
            self.tables.append(node)
    
        def depart_table(self, node):
            self.tables.pop()
    

    Notice that I'm doing this with other nodes besides the table node. For example, I do this with thead, tbody and row.

        def visit_row(self, node):
            if not len(self.theads) and not len(self.tbodys):
                raise nodes.SkipNode
            self.rows.append(node)
    
        def depart_row(self, node):
            self.add('|\n')
            if not len(self.theads):
                self.row_entries = []
            self.rows.pop()
    

    Keeping track of where you are in the table (basically reference counting) simplifies the code. Instead of using integer counters, I am using arrays of nodes. This allows referencing the nodes from other visit methods. This can come in handy quite often. For example, I use the "reference counting node arrays" to generate padding in the table entries making the tables look much prettier.

    Basically, I am finding the largest string in a column and using it to calculate the padding. This would be very challenging if I did not have access to nodes outside of the current node.

        @property
        def rows(self):
            rows = []
            if not len(self.tables):
                return rows
            for node in self.tables[len(self.tables) - 1].children:
                if isinstance(node, nodes.row):
                    rows.append(node)
                else:
                    for node in node.children:
                        if isinstance(node, nodes.row):
                            rows.append(node)
            return rows
    
        def depart_entry(self, node):
            length = 0
            i = len(self.row_entries) - 1
            for row in self.rows:
                if len(row.children) > i:
                    entry_length = len(row.children[i].astext())
                    if entry_length > length:
                        length = entry_length
            padding = ''.join(_.map(range(length - len(node.astext())), lambda: ' '))
            self.add(padding + ' ')
    

    https://github.com/codejamninja/sphinx-markdown-builder/blob/master/sphinx_markdown_builder/markdown_writer.py#L320-L329

    I am thinking about possibly implementing this reference counting across all of the nodes. It could simplify the design of some of the more complex transpiling.

    Please discuss the reference counting more at the issue below. #8

    opened by clayrisser 6
  • Permit requirements to be x or higher

    Permit requirements to be x or higher

    • Allow higher versions of Sphinx
    • Lower versions of Sphinx may work, but haven't been tested
    • Sphinx limited to version < 2
    • All other libraries unrestricted, but should later be restricted if breaking changes are made, or if they are found to use semantic versioning and can be range-limited, as done with Sphinx
    opened by eode 6
  • master file ..\docs\contents.rst not found

    master file ..\docs\contents.rst not found

    I have sphinx-build 1.8.3.

    From what I've been following, I only need an index.rst file initially. When I try to run make markdown, it's looking for a file .\docs\contents.rst , which by default I don't have.

    I assume this might be configured to work with an older version of sphinx that included a contents.rst by default?

    I created a contents.rst file and put some dummy content in, and then it ran just fine.

    opened by ahalota 4
  • Preserve language domain when converting language blocks

    Preserve language domain when converting language blocks

    Markdown conversion does not preserve restructuredtext code blocks such as:

    
    .. code-block:: python
        import math
    
    .. literalinclude:: test.py
        :language: python
    
    .. highlight:: bash
    
    ::
        cat *.rst
    
    

    And render it in markdown as (without the spaces I've used as escape characters for the backticks):

    
    `` `python
    import math
    ` ``
    
    ...
    
    `` `bash
    cat *.rst
    ` ``
    
    
    opened by Liam-Deacon 4
  • failed on sphinx 1.5.1

    failed on sphinx 1.5.1

    better to support some older versions, on 1.5.1 it fails with

    sphinx-build -b markdown doc/ doc/_build/ -E
    Running Sphinx v1.5.1
    /xxx/.virtualenvs/log/lib/python3.6/site-packages/matplotlib/font_manager.py:232: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
      'Matplotlib is building the font cache using fc-list. '
    
    Extension error:
    Could not import extension sphinx_markdown_builder (exception: cannot import name '__')
    
    opened by DeoLeung 4
  • Use version ranges instead of pinning exact versions

    Use version ranges instead of pinning exact versions

    I'm trying to use your library on Python 3 and with Sphinx 2.0.1, and I have noticed that your package pins every package it depends on, this makes it very difficult to use new Sphinx versions.

    opened by software-opal 3
  • Fix markdown links

    Fix markdown links

    Cross references between markdown files created from auto-generated documentation via sphinx-apidoc were all listed as [...](#None).

    This was due to faulty return values for markdown_builder.get_target_uri() and doctree2md._refuri2http().

    See #20

    opened by FabianNiehaus 2
  • README typo?

    README typo?

    I'm a bit confused about the "Usage" section of the README:

    from sphinx_markdown_parser.markdown_builder import MarkdownBuilder
    
    source_suffix = {
        '.rst': 'restructuredtext',
        '.md': 'markdown'
    }
    
    def setup(app):
        app.add_source_suffix('.md', 'markdown')
        app.add_source_parser(MarkdownParser)
    

    Should this be from sphinx_markdown_builder.markdown_build import MarkdownBuilder instead of from sphinx_markdown_parser.markdown_builder import MarkdownBuilder. Also I think app.add_source_parser(MarkdownParser) should be app.add_source_parser(MarkdownBuilder), otherwise, where is MarkdownParser imported from/defined at?

    opened by lematt1991 2
  • Class are now at a superior title level than methods

    Class are now at a superior title level than methods

    When I did PR #38 I made a mistake resulting in classes being at an inferior title level than methods while the opposite was expected. It is now fixed

    opened by avaliente-bc 2
  • Classes and methods are not at the same title level

    Classes and methods are not at the same title level

    Today, when generating markdown files, classes and methods from theses classes appears at the same title level which is kind of annoying. I put classes at a higher level than methods to fix this.

    opened by avaliente-bc 2
  • update requirements file

    update requirements file

    Is it possible to remove the strict version matching for the required packages in favor of the greater then equals sign (>=) ?

    The package fails on newer versions of sphinx (i.e. 2.2.0) which also installs newer version of docutils (0.15.x).

    opened by bennymeg 2
  • Add `singlemarkdown` mode to help with internal project development

    Add `singlemarkdown` mode to help with internal project development

    Being able to produce a single README.md that has the entire output would be valuable for teams using products like GitHub that want to make sure there is "go to" documentation for every repository.

    opened by whardier 2
  • Lists have too much blank space

    Lists have too much blank space

    This .rst:

    Simple Lists
    ------------
    
    - Item 1
    - Item 2
    - Item 3
    

    is output as:

    # Simple Lists
    
    
    * Item 1
    
    
    * Item 2
    
    
    * Item 3
    

    When rendered, this puts too much space between the list items.

    It renders on GitHub like this: image

    If the markdown instead were this:

    # Simple Lists
    
    * Item 1
    * Item 2
    * Item 3
    

    then it would render as: image

    opened by nedbat 1
  • Apply to be Co-Maintainer of sphinx-markdown-builder

    Apply to be Co-Maintainer of sphinx-markdown-builder

    I had sent mail to you but get no response, so I file issue here :)


    Hello clayrisser,

    I am a power Sphinx user[1] and I wrote many Sphinxextensions[2].

    sphinx-markdown-builder is a awesome project, but it has some BUGs. I filed a PR[3] to fix one of theme, I hope it can be merged. But it seems that you are no longer active on this project. Contribute is always better than fork, can I apply to be the co-maintainer of this project?

    If you agree, please also add me[4] as Co-Maintainer on pypi.

    [1] https://github.com/SilverRainZ/bullet/blob/master/conf.py [2] https://github.com/sphinx-notes [3] https://github.com/clayrisser/sphinx-markdown-builder/pull/57 [4] https://pypi.org/user/SilverRainZ/

    -- Best regards, Shengyu Zhang

    https://silverrainz.me/

    opened by SilverRainZ 5
  • Fix table and list item: paragraph in these nodes do not need newline

    Fix table and list item: paragraph in these nodes do not need newline

    A paragraph maybe child of a table entry or list item, we should not add newline in these cases. See commit message and comments of code.

    Table

    rST source:

    .. list-table::
       :header-rows: 1
    
       * - Type
         - Variant
       * - ``any``
         - ``Stream``
       * - ``comparable``
         - ``Comparable``
    

    Generated markdown:

    | Type
    
     | Variant
    
     |
    | ------------------- | ---------------------------------------------------------------- |  |  |
    | `any`
    
                     | `Stream`
    
                                                               |
    | `comparable`
    
              | `Comparable`
    
                                                           |
    

    After this patch:

    | Type | Variant |
    | ------------------- | ---------------------------------------------------------------- |  |  |
    | `any`                 | `Stream`                                                           |
    | `comparable`          | `Comparable`                                                       |
    

    List

    rST source:

    1. Use ``FromSlice`` to construct a stream of int slice.
    2. Use ``Filter`` to filter the zero values.
    3. Use ``ToSlice`` convered filtered stream to slice, evaluation is done here.
    

    Generated markdown:

    1. Use `FromSlice` to construct a stream of int slice.
    
    
    2. Use `Filter` to filter the zero values.
    
    
    3. Use `ToSlice` convered filtered stream to slice, evaluation is done here.
    

    After this patch:

    1. Use `FromSlice` to construct a stream of int slice.
    2. Use `Filter` to filter the zero values.
    3. Use `ToSlice` convered filtered stream to slice, evaluation is done here.
    
    opened by SilverRainZ 4
  • Fix new line insertion  inside table cells text

    Fix new line insertion inside table cells text

    rst table construction:

    .. table:: Тест
        ====== ==============================================================================
        х1      x2
        ====== ==============================================================================
        d1     d2
               d4
        d5     d6       
        ====== ==============================================================================
    

    converted to wrong syntax

    . . . 
    | d1  | d2
    d4
    |
    . . . 
    

    It is incorrect in terms of Markdown. All table cell context should be in one line. So I fix this. I test it using methods overload in conf.py in my current sphinx-doc documentation.

    For mow it produce

    | х1 | x2 |
    | ------ | ------------------------------------------------------------------------------ |
    | d1 | d2<br>Переменные события пересечения порога для метрики объекта |
    | d5 | d6 |
    

    Unfortunately, It steels has problems with correct column width detection ( made some trick in this example) and i steel work on solution.

    opened by abel-msk 0
Releases(0.5.3)
Owner
Clay Risser
Open source software engineer proficient with React, NodeJS, TypeScript and Kubernetes
Clay Risser
Python script to generate Vale linting rules from word usage guidance in the Red Hat Supplementary Style Guide

ssg-vale-rules-gen Python script to generate Vale linting rules from word usage guidance in the Red Hat Supplementary Style Guide. These rules are use

Vale at Red Hat 1 Jan 13, 2022
Variable Transformer Calculator

✠ VASCO - VAriable tranSformer CalculatOr Software que calcula informações de transformadores feita para a matéria de "Conversão Eletromecânica de Ene

Arthur Cordeiro Andrade 2 Feb 12, 2022
Bring RGB to life in Neovim

Bring RGB to life in Neovim Change your RGB devices' color depending on Neovim's mode. Fast and asynchronous plugin to live your vim-life to the fulle

Antoine 40 Oct 27, 2022
Main repository for the Sphinx documentation builder

Sphinx Sphinx is a tool that makes it easy to create intelligent and beautiful documentation for Python projects (or other documents consisting of mul

5.1k Jan 02, 2023
Software engineering course project. Secondhand trading system.

PigeonSale Software engineering course project. Secondhand trading system. Documentation API doumenatation: list of APIs Backend documentation: notes

Harry Lee 1 Sep 01, 2022
Showing potential issues with merge strategies

Showing potential issues with merge strategies Context There are two branches in this repo: main and a feature branch feat/inverting-method (not the b

Rubén 2 Dec 20, 2021
A comprehensive and FREE Online Python Development tutorial going step-by-step into the world of Python.

FREE Reverse Engineering Self-Study Course HERE Fundamental Python The book and code repo for the FREE Fundamental Python book by Kevin Thomas. FREE B

Kevin Thomas 7 Mar 19, 2022
YAML metadata extension for Python-Markdown

YAML metadata extension for Python-Markdown This extension adds YAML meta data handling to markdown with all YAML features. As in the original, metada

Nikita Sivakov 14 Dec 30, 2022
Pyoccur - Python package to operate on occurrences (duplicates) of elements in lists

pyoccur Python Occurrence Operations on Lists About Package A simple python package with 3 functions has_dup() get_dup() remove_dup() Currently the du

Ahamed Musthafa 6 Jan 07, 2023
My solutions to the Advent of Code 2021 problems in Go and Python 🎄

🎄 Advent of Code 2021 🎄 Summary Advent of Code is an annual Advent calendar of programming puzzles. This year I am doing it in Go and Python. Runnin

Orfeas Antoniou 16 Jun 16, 2022
pytorch_example

pytorch_examples machine learning site map 정리자료 Resnet https://wolfy.tistory.com/243 convolution 연산 정리 https://gaussian37.github.io/dl-concept-covolut

injae hwang 1 Nov 24, 2021
Workbench to integrate pyoptools with freecad, that means basically optics ray tracing capabilities for FreeCAD.

freecad-pyoptools Workbench to integrate pyoptools with freecad, that means basically optics ray tracing capabilities for FreeCAD. Requirements It req

Combustión Ingenieros SAS 12 Nov 16, 2022
Generate YARA rules for OOXML documents using ZIP local header metadata.

apooxml Generate YARA rules for OOXML documents using ZIP local header metadata. To learn more about this tool and the methodology behind it, check ou

MANDIANT 34 Jan 26, 2022
Example Python code for running the mango-explorer marketmaker

🥭 Mango Explorer 📖 Introduction This guide will show you how to load and run a customisable marketmaker that runs on Mango Markets using the mango-e

Blockworks Foundation 2 Apr 11, 2022
✨ Real-life Data Analysis and Model Training Workshop by Global AI Hub.

🎓 Data Analysis and Model Training Course by Global AI Hub Syllabus: Day 1 What is Data? Multimedia Structured and Unstructured Data Data Types Data

Global AI Hub 71 Oct 28, 2022
A next-generation curated knowledge sharing platform for data scientists and other technical professions.

Knowledge Repo The Knowledge Repo project is focused on facilitating the sharing of knowledge between data scientists and other technical roles using

Airbnb 5.2k Dec 27, 2022
Essential Document Generator

Essential Document Generator Dead Simple Document Generation Whether it's testing database performance or a new web interface, we've all needed a dead

Shane C Mason 59 Nov 11, 2022
Data-science-on-gcp - Source code accompanying book: Data Science on the Google Cloud Platform, Valliappa Lakshmanan, O'Reilly 2017

data-science-on-gcp Source code accompanying book: Data Science on the Google Cloud Platform, 2nd Edition Valliappa Lakshmanan O'Reilly, Jan 2022 Bran

Google Cloud Platform 1.2k Dec 28, 2022
Create docsets for Dash.app-compatible API browser.

doc2dash: Create Docsets for Dash.app and Clones doc2dash is an MIT-licensed extensible Documentation Set generator intended to be used with the Dash.

Hynek Schlawack 498 Dec 30, 2022
A tutorial for people to run synthetic data replica's from source healthcare datasets

Synthetic-Data-Replica-for-Healthcare Description What is this? A tailored hands-on tutorial showing how to use Python to create synthetic data replic

11 Mar 22, 2022