From 881af486e64ed0c05cd74a4e56740a4a95e77366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Duy=C3=A9?= Date: Mon, 21 Mar 2016 12:47:51 +0100 Subject: [PATCH 1/2] Rename README => README.md --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From e98da2273c175508238068d87517cdba8f1b2419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Duy=C3=A9?= Date: Mon, 21 Mar 2016 13:38:09 +0100 Subject: [PATCH 2/2] Add some basic examples to get quickly ready --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 44ad192..c1b684f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,57 @@ -For example usage, see the code in the unit tests in the 'test' directory and -its subdirectories. +## Basic examples + +### Hello World + +```python +from rtfng.Elements import Document, Section + +doc = Document() +section = Section() +section.append('Hello world !') +doc.Sections.append(section) + +doc.write(file('hello.rtf', 'w')) +``` + +### Example 1 + +```python +from rtfng.Elements import Document, Section +from rtfng.document.paragraph import Paragraph +from rtfng.document.character import TEXT + +# Init +doc = Document() +section = Section() + +# First paragraph +p = Paragraph() +p.append('It is also possible to manully override a style:', + TEXT(' this is a change of the font size', size=48), + '.') +section.append(p) + +# Empty paragraph +section.append('') + +# Second paragraph +p = Paragraph() +p.append('This is a ', + TEXT('very important information !', colour=doc.StyleSheet.Colours.Red, underline=True, bold=True) + ) +# Have a look to TEXT() definition in rtfng/document/character.py for more options + +section.append(p) +doc.Sections.append(section) + +doc.write(file('example.rtf', 'w')) +``` + +## Tests + +For example usage, see the code in the unit tests in the 'test' directory and its subdirectories. To run all tests: python test/test_all.py python test/test_doctests.py -