Skip to content

Commit

Permalink
Use README as home page of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
victorbnl committed Oct 10, 2023
1 parent 26e79e5 commit 814cbae
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 88 deletions.
82 changes: 0 additions & 82 deletions README.md

This file was deleted.

93 changes: 93 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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/
7 changes: 1 addition & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
Code-to-PDF
===========

.. toctree::
:hidden:
:maxdepth: 1
Expand All @@ -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

0 comments on commit 814cbae

Please sign in to comment.