From 814cbae39ef0a7c16e3620d77cb82c2561af6493 Mon Sep 17 00:00:00 2001 From: Victor Bonnelle Date: Tue, 10 Oct 2023 12:05:18 +0200 Subject: [PATCH] Use README as home page of documentation --- README.md | 82 -------------------------------------------- README.rst | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 7 +--- 3 files changed, 94 insertions(+), 88 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 6db2305..0000000 --- a/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# Code-to-PDF - -[![](https://img.shields.io/badge/v1.2.0-_?label=documentation)](https://victorbnl.github.io/code-to-pdf/) - -> Generate PDF documents from source code with syntax highlighting. - -

- -

- -## Motivation - -I created this project because my school teacher preferred to get our homework -as PDF files rather than source files. So I figured I’d automate it to save -myself from copying the code in LibreOffice Writer for each homework. - -## Requirements - -- `pdflatex` - -## Installation - -``` -pip install git+https://github.com/victorbnl/code-to-pdf -``` - -## Usage - -### As a command-line application - -``` -usage: code-to-pdf [-h] [-s STYLE] [--font-size FONT_SIZE] [--linenos LINENOS] [--linenostep LINENOSTEP] [--page-numbers PAGE_NUMBERS] - [--top-margin TOP_MARGIN] [--bottom-margin BOTTOM_MARGIN] [--left-margin LEFT_MARGIN] [--right-margin RIGHT_MARGIN] - source_file out_file - -positional arguments: - source_file file to get source code from - out_file output PDF file - -options: - -h, --help show this help message and exit - -s STYLE, --style STYLE - pygments style (see https://pygments.org/styles/) - --font-size FONT_SIZE - document font size - --linenos LINENOS whether or not to display line numbers - --linenostep LINENOSTEP - if `linenos` is enabled, print every n-th line number - --page-numbers PAGE_NUMBERS - whether or not to print page numbers - --top-margin TOP_MARGIN - document top margin - --bottom-margin BOTTOM_MARGIN - document bottom margin - --left-margin LEFT_MARGIN - document left margin - --right-margin RIGHT_MARGIN - document right margin -``` - -> **Note**
-> See [Pygments’ documentation](https://pygments.org/styles/) for a list of -> available styles. - -### As a module - -```python ->>> import code_to_pdf ->>> source = "print('Hello world!')" ->>> options = code_to_pdf.Options() ->>> pdf_content = code_to_pdf.build(source, options=options) ->>> with open('output.pdf', 'wb') as output_file: -... output_file.write(pdf_content) -``` - -> **Note**
-> See [Options](https://victorbnl.github.io/code-to-pdf/options.html) for a list -> of options. - -## Thanks to - -- [Pygments](https://pygments.org/), which this project highly relies upon diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..8305b03 --- /dev/null +++ b/README.rst @@ -0,0 +1,93 @@ +Code-to-PDF +=========== + +.. image:: + https://img.shields.io/badge/v1.2.0-_?label=documentation + :target: https://victorbnl.github.io/code-to-pdf/ + +Generate PDF documents from source code with syntax highlighting. + +.. image:: + https://github.com/victorbnl/code-to-pdf/blob/main/docs/_static/screenshot.png?raw=true + +Motivation +---------- + +I created this project because my school teacher preferred to get our homework +as PDF files rather than source files. So I figured I’d automate it to save +myself from copying the code in LibreOffice Writer for each homework. + +Requirements +------------ + +- pdflatex + +Installation +------------ + +.. code-block:: + + pip install git+https://github.com/victorbnl/code-to-pdf + +Usage +----- + +As a command-line application +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: + + usage: code-to-pdf [-h] [-s STYLE] [--font-size FONT_SIZE] [--linenos LINENOS] [--linenostep LINENOSTEP] [--page-numbers PAGE_NUMBERS] + [--top-margin TOP_MARGIN] [--bottom-margin BOTTOM_MARGIN] [--left-margin LEFT_MARGIN] [--right-margin RIGHT_MARGIN] + source_file out_file + + positional arguments: + source_file file to get source code from + out_file output PDF file + + options: + -h, --help show this help message and exit + -s STYLE, --style STYLE + pygments style (see https://pygments.org/styles/) + --font-size FONT_SIZE + document font size + --linenos LINENOS whether or not to display line numbers + --linenostep LINENOSTEP + if `linenos` is enabled, print every n-th line number + --page-numbers PAGE_NUMBERS + whether or not to print page numbers + --top-margin TOP_MARGIN + document top margin + --bottom-margin BOTTOM_MARGIN + document bottom margin + --left-margin LEFT_MARGIN + document left margin + --right-margin RIGHT_MARGIN + document right margin + +.. note:: + See `Pygments styles`_ for a list of available styles. + +As a module +^^^^^^^^^^^ + +.. code-block:: + + >>> import code_to_pdf + >>> source = "print('Hello world!')" + >>> options = code_to_pdf.Options() + >>> pdf_content = code_to_pdf.build(source, options=options) + >>> with open('output.pdf', 'wb') as output_file: + ... output_file.write(pdf_content) + +.. note:: + See `Options`_ for a list of options. + +Thanks to +--------- + +- `Pygments`_, which this project highly relies upon. + +.. _Pygments styles: https://pygments.org/styles/ +.. _Options: https://victorbnl.github.io/code-to-pdf/options.html +.. _Pygments: https://pygments.org/ diff --git a/docs/index.rst b/docs/index.rst index 29b1fb1..c8451d5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,6 +1,3 @@ -Code-to-PDF -=========== - .. toctree:: :hidden: :maxdepth: 1 @@ -9,6 +6,4 @@ Code-to-PDF build options -Generate PDF documents from source code with syntax highlighting. - -.. image:: _static/screenshot.png +.. include:: ../README.rst