Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Noweb's input  



1.1  Example of a simple Noweb program  







2 Compatibility  





3 See also  





4 Notes  





5 External links  














Noweb






Català
Deutsch
Հայերեն
Polski
 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Noweb
Original author(s)Norman Ramsey
Initial release1989, 34–35 years ago
Stable release

2.12 / 28 June 2018; 6 years ago (2018-06-28)[1]

Repository
Written inC, AWK, and Icon
Operating systemCross-platform
Available inEnglish
TypeLiterate programming
LicenseBSD-2-Clause license
Websitewww.cs.tufts.edu/~nr/noweb/ Edit this at Wikidata

Noweb, stylised in lowercase as noweb, is a literate programming tool, created in 1989–1999 by Norman Ramsey,[1] and designed to be simple, easily extensible and language independent.[2][3]

As in WEB and CWEB, the main components of Noweb are two programs: "notangle", which extracts 'machine' source code from the source texts, and "noweave", which produces nicely-formatted printable documentation.

Noweb supports TeX, LaTeX, HTML, and troff back ends and works with any programming language. Besides simplicity this is the main advantage over WEB, which needs different versions to support programming languages other than Pascal. (Thus the necessity of CWEB, which supports C and similar languages.)

Noweb's input

[edit]

A Noweb input text contains program source code interleaved with documentation. It consists of so-called chunks that are either documentation chunksorcode chunks.

A documentation chunk begins with a line that starts with an at sign (@) followed by a space or newline. A documentation chunk has no name. Documentation chunks normally contain LaTeX, but Noweb is also used with HTML, plain TeX, and troff.

Code chunks are named. A code chunk begins with

<<chunk name>>=

on a line by itself. The double left angle bracket (<<) must be in the first column.

Each chunk is terminated by the beginning of another chunk. If the first line in the file does not mark the beginning of a chunk, it is assumed to be the first line of a documentation chunk.

Code chunks aren't treated specially by Noweb's tools—they may be placed in any order and, when needed, they are just concatenated. Chunk references in code are dereferenced and the whole requested source code is extracted.

Example of a simple Noweb program

[edit]

This is an example of a "hello world" program with documentation:

\section{Hello world}

Today I awoke and decided to write
some code, so I started to write Hello World in \textsf C.

<<hello.c>>=
/*
  <<license>>
*/
#include <stdio.h>

int main(int argc, char *argv[]) {
  printf("Hello World!\n");
  return 0;
}
@
\noindent \ldots then I did the same in PHP.

<<hello.php>>=
<?php
  /*
  <<license>>
  */
  echo "Hello world!\n";
?>
@
\section{License}
Later the same day some lawyer reminded me about licenses.
So, here it is:

<<license>>=
This work is placed in the public domain.

Assuming that the above code is placed in a file named 'hello.nw', the command to extract the human-readable document in HTML format is:

noweave -filter l2h -index -html hello.nw | htmltoc > hello.html

... and in LaTeX format:

noweave -index -latex hello.nw > hello.tex

To extract machine source code:

notangle -Rhello.c hello.nw > hello.c
notangle -Rhello.php hello.nw > hello.php

Compatibility

[edit]

Noweb defines a specific file format and a file is likely to interleave three different formats (Noweb, LaTeX and the language used for the software). This is not recognised by other software development tools and consequently using Noweb excludes the use of UML or code documentation tools.

See also

[edit]

Notes

[edit]
  1. ^ a b "Noweb home page". 24 April 2016. Retrieved 21 March 2018.
  • ^ Ramsey, N. (September 1994). "Literate programming simplified". IEEE Software. 11 (5): 97–105. doi:10.1109/52.311070. S2CID 18593796. Retrieved 3 December 2018.
  • ^ Johnson, Andrew L.; Johnson, Brad (October 1, 1997). "Literate Programming Using Noweb | Linux Journal". www.linuxjournal.com. Retrieved 3 December 2018.
  • [edit]
    Retrieved from "https://en.wikipedia.org/w/index.php?title=Noweb&oldid=1192274426"

    Categories: 
    Free documentation generators
    Source code documentation formats
    Literate programming
    Troff
    Hidden categories: 
    Articles with short description
    Short description matches Wikidata
     



    This page was last edited on 28 December 2023, at 14:59 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki