Text grammar

A text grammar is the study of texts above the level of the sentence. It shows how texts are put together so as to convey ideas, facts, messages, and fiction. 
A similar term is discourse analysis. Both are mostly concerned with natural language use; discourse analysis would include spoken language. Speech is also the parent of rhetoric, the ancient study of persuasive speaking. In a similar way, literary criticism parallels text grammar, because both concentrate on the printed word. A text grammar approach puts emphasis on the linguistic structure of a text, rather than its cultural or symbolic meaning.
A text is a coherent body of sentences. Coherent means they are linked by a consistent "theme". The text ends when "completion" is signalled. For example, when a problem introduced at the start is solved, or when a promised discussion has reached a conclusion. 
Text types.
Each text focuses on certain things. If texts are grouped by what they are doing, then there are five basic text types:
Many texts, of course, can and do have a mixture of two or more of these types.