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
Read write method - Read files in various types of formats

一个关于所有格式文件读取的方法 1。 问题描述: 各种各样的文件格式,读写操作非常的麻烦,能够有一种方法,可以整合所有格式的文件,方便用户进行读取和写入。 2

2 Jan 26, 2022
Project created to help beginner programmers to study, despite the lack of internet!

Project created to help beginner programmers to study, despite the lack of internet!

Dev4Dev 2 Oct 25, 2021
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
An MkDocs plugin that simplifies configuring page titles and their order

MkDocs Awesome Pages Plugin An MkDocs plugin that simplifies configuring page titles and their order The awesome-pages plugin allows you to customize

Lukas Geiter 282 Dec 28, 2022
A markdown wiki and dashboarding system for Datasette

datasette-notebook A markdown wiki and dashboarding system for Datasette This is an experimental alpha and everything about it is likely to change. In

Simon Willison 19 Apr 20, 2022
A python package to import files from an adjacent folder

EasyImports About EasyImports is a python package that allows users to easily access and import files from sister folders: f.ex: - Project - Folde

1 Jun 22, 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
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.

Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, A

Donne Martin 24.5k Jan 09, 2023
This is a tool to make easier brawl stars modding using csv manipulation

Brawler Maker : Modding Tool for Brawl Stars This is a tool to make easier brawl stars modding using csv manipulation if you want to support me, just

6 Nov 16, 2022
This programm checks your knowlege about the capital of Japan

Introduction This programm checks your knowlege about the capital of Japan. Now, what does it actually do? After you run the programm you get asked wh

1 Dec 16, 2021
Sphinx-performance - CLI tool to measure the build time of different, free configurable Sphinx-Projects

CLI tool to measure the build time of different, free configurable Sphinx-Projec

useblocks 11 Nov 25, 2022
Beautiful static documentation generator for OpenAPI/Swagger 2.0

Spectacle The gentleman at REST Spectacle generates beautiful static HTML5 documentation from OpenAPI/Swagger 2.0 API specifications. The goal of Spec

Sourcey 1.3k Dec 13, 2022
Generate a backend and frontend stack using Python and json-ld, including interactive API documentation.

d4 - Base Project Generator Generate a backend and frontend stack using Python and json-ld, including interactive API documentation. d4? What is d4 fo

Markus Leist 3 May 03, 2022
Reproducible Data Science at Scale!

Pachyderm: The Data Foundation for Machine Learning Pachyderm provides the data layer that allows machine learning teams to productionize and scale th

Pachyderm 5.7k Dec 29, 2022
MonsterManualPlus - An advanced monster manual for Tower of the Sorcerer.

Monster Manual + This is an advanced monster manual for Tower of the Sorcerer mods. Users can get a plenty of extra imformation for decision making wh

Yifan Zhou 1 Jan 01, 2022
My Sublime Text theme

rsms sublime text theme Install: cd path/to/your/sublime/packages git clone https://github.com/rsms/sublime-theme.git rsms-theme You'll also need the

Rasmus 166 Jan 04, 2023
MkDocs plugin for setting revision date from git per markdown file

mkdocs-git-revision-date-plugin MkDocs plugin that displays the last revision date of the current page of the documentation based on Git. The revision

Terry Zhao 48 Jan 06, 2023
Rust Markdown Parsing Benchmarks

Rust Markdown Parsing Benchmarks This repo tries to assess Rust markdown parsing

Ed Page 1 Aug 24, 2022
Soccerdata - Efficiently scrape soccer data from various sources

SoccerData is a collection of wrappers over soccer data from Club Elo, ESPN, FBr

Pieter Robberechts 195 Jan 04, 2023
Ultimaker Cura 2 Mooraker Upload Plugin

Klipper & Cura - Cura2MoonrakerPlugin Allows you to upload Gcode directly from Cura to your Klipper-based 3D printer (Fluidd, Mainsailos etc.) using t

214 Jan 03, 2023