NANOLP
Introduction to LP LP : Literate Programming - more reliable, readable, supportable
Benefits of LP● Makes programming fine!● Is good for children teaching● Is good for books, articles...● Is goo...
How to achieve this? try new free tool NanoLP
History. New terminology● introduced by Donald ● chunk — piece of code Knuth near 19...
Problems with old tools● weird syntax● only one input files format (based on TeX, LaTeX, XML...)● presentation...
How it looksTo test if number is positive(pos), use: `n >= 0`. Now Simple exampleabsolute function will be: ...
How it looksStandard C headers guard(hguard) is: Flex macros: #ifndef ${file}_H ● ...
How it looks #ifndef PRN_H #define PRN_H #define PRN(x) printf(x) #endifand result will be saved in „prn.h“
How it looksStandard C headers guard(hguard) is: WYSIWYG way: #ifndef ${file}_H #define ${file}_H ...
More examples See test/tests folder in source archive...
NanoLP advantages● Clean, human (book) oriented syntax● Standard documents formats● Flex macros system● Fetchi...
Documents formats● OpenOffice, LibreOffice ● TeX/LaTeX● Markdown ...
Code sources fetching● via FTP (authorized too)● via HTTP (authorized too)● from ZIP archive (crypted too)● fr...
Publishing on the Web1. Generated cross-references file2. Raw documents (Creole, Markdown, etc)3. Converted to HTML docume...
Publishing consinstead of corporative Wiki with out-of-dated codedocumentation...use forever actual documentation with:● ...
Syntax concept● …command...chunk… – define named chunk● …sys command…command…chunk... – exec sys command, ...
How it is parsingextracted:● commands● inline chunks● block chunks□ commands in doc fragment are surrounded by...
System commands● import another code sources● flush result to files● create variables or maps of them● catch e...
Code transformation● paste Customize via:● substitute vars ● ...
Code transformationIt is possible to paste «mystructs»: [[=mystructs, one, two, three]]and to get: struct mystruct m[] = {...
Other customization● Surround symbols ● Custom sys● Input format command...
Details● Supported UTF-8● Python 2.7 - 3+ compatible● Works on Linux, Windows● Many tests are provided● Fre...
More info Project home: http://code.google.com/p/nano-lp/ Blog: http://balkansoft.blogspot.com/
of 24

NanoLP tool

New Literate Programming Tool
Published on: Mar 3, 2016
Source: www.slideshare.net


Transcripts - NanoLP tool

  • 1. NANOLP
  • 2. Introduction to LP LP : Literate Programming - more reliable, readable, supportable
  • 3. Benefits of LP● Makes programming fine!● Is good for children teaching● Is good for books, articles...● Is good for collaborative working● Makes software supportable● Makes code readable (and printable)● Reduces bugs!
  • 4. How to achieve this? try new free tool NanoLP
  • 5. History. New terminology● introduced by Donald ● chunk — piece of code Knuth near 1970s ● command — macros surrounder — strings used alternative to the ●● as left, right surround structured command symbols programming paradigm ● fetcher — method of source retrieving● tools: WEB, CWEB, noweb...
  • 6. Problems with old tools● weird syntax● only one input files format (based on TeX, LaTeX, XML...)● presentation facilities are limited by input format● no publishing facility● weak code transformation● not extendible, not scriptable
  • 7. How it looksTo test if number is positive(pos), use: `n >= 0`. Now Simple exampleabsolute function will be: ● easy to read int abs(int n) { ● flow of thoughts if ( [[=pos]] ) return n; ● free structure else return -n; ● doc formatting } ● images, tables, Markdown diagrams, links, etc...
  • 8. How it looksStandard C headers guard(hguard) is: Flex macros: #ifndef ${file}_H ● placeholders #define ${file}_H ● multipartand `#endif` at the end. So ● saving to file(file.x, prn.h): [[=hguard.0, file:PRN]] ● multiple output files #define PRN(x) printf(x) ● and more options... [[=hguard.1] Markdown see result ►
  • 9. How it looks #ifndef PRN_H #define PRN_H #define PRN(x) printf(x) #endifand result will be saved in „prn.h“
  • 10. How it looksStandard C headers guard(hguard) is: WYSIWYG way: #ifndef ${file}_H #define ${file}_H ● edit result doc ● no special syntaxand #endif at the end. So(file.x, prn.h): ● rich styling [[=hguard.0, file:PRN]] #define PRN(x) printf(x) ● easy for diagrams, [[=hguard.1] tables, etc... OpenOffice
  • 11. More examples See test/tests folder in source archive...
  • 12. NanoLP advantages● Clean, human (book) oriented syntax● Standard documents formats● Flex macros system● Fetching sources via different protocols● Highly customizable, extendible● Publishing code on the Web● Imports and many more...!
  • 13. Documents formats● OpenOffice, LibreOffice ● TeX/LaTeX● Markdown ● HTML/XML● MultiMarkdown ● AsciiDoc● ReStructuredText ● Txt2Tags● CreoleWork in WYSIWYG office suite or with Wiki tools,or even with publishing systems!
  • 14. Code sources fetching● via FTP (authorized too)● via HTTP (authorized too)● from ZIP archive (crypted too)● from shell command output● ...and sure from local FSUser can add custom fetchers!
  • 15. Publishing on the Web1. Generated cross-references file2. Raw documents (Creole, Markdown, etc)3. Converted to HTML documents4. Special published HTML documents1: Total info, list of chunks, interactive links4: Converted LP macroses to interactive linksCustom styling is supported
  • 16. Publishing consinstead of corporative Wiki with out-of-dated codedocumentation...use forever actual documentation with:● navigation● source extracting● source importing● good for reading, printing, teaching
  • 17. Syntax concept● …command...chunk… – define named chunk● …sys command…command…chunk... – exec sys command, followed by case 1)● ...command...chunk...chunk... – define multipart named chunk - sys commands are executed - named chunks are pasted
  • 18. How it is parsingextracted:● commands● inline chunks● block chunks□ commands in doc fragment are surrounded by 2 strings: [[,]] or <<,>> or any user defined□ commands in code fragment are surrounded by 2 strings: [[,]] or <<,>> or any user defined□ pasted commands begins with = symbol
  • 19. System commands● import another code sources● flush result to files● create variables or maps of them● catch events...
  • 20. Code transformation● paste Customize via:● substitute vars ● events● transform of vars ● parameters● transform of chunks ● positional args● custom join of chunks ● keyword args● custom join of vars
  • 21. Code transformationIt is possible to paste «mystructs»: [[=mystructs, one, two, three]]and to get: struct mystruct m[] = { { ONE, ˝one˝}, { TWO, ˝two˝}, { THREE, ˝three˝} }; See events catching about it
  • 22. Other customization● Surround symbols ● Custom sys● Input format commands detection ● Custom fetchers● Parsing options ● Custom parsers● Custom styles (via ● Custom event CSS) handlers
  • 23. Details● Supported UTF-8● Python 2.7 - 3+ compatible● Works on Linux, Windows● Many tests are provided● Free and open source● GNU licensed
  • 24. More info Project home: http://code.google.com/p/nano-lp/ Blog: http://balkansoft.blogspot.com/

Related Documents