I assume that you want to achieve something like the PGF manual. Perhaps the best way is to have a copy of pgfmanual-en-macros.tex and write:
\documentclass{ltxdoc}
\usepackage[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry}
\usepackage{tikz}
\let\setlength\pgfmathsetlength
\input pgfmanual-en-macros.tex
Now you can write something like the manual:
\begin{document}
\subsubsection{Horizontal and Vertical Shadings}
Declares a horizontal shading named \meta{shading name} of the specified
\meta{height} with the specified colors. The width of the bar is
deduced automatically from the maximum dimension in the specification.
\begin{codeexample}[]
\pgfdeclarehorizontalshading{myshadingA}
{1cm}{rgb(0cm)=(1,0,0); color(2cm)=(green); color(4cm)=(blue)}
\pgfuseshading{myshadingA}
\end{codeexample}
The effect of the \meta{color list}, which is a
comma-separated list of colors, is the following: Normally, when
this list is empty, once a shading has been declared, it becomes
``frozen.'' This means that even if you change a color that was used
in the declaration of the shading later on, the shading will not
change. By specifying a \meta{color list} you can specify
that the shading should be recalculated whenever one of the colors
listed in the list changes (this includes effects like color
mixins). Thus, when you specify a \meta{color list}, % TODOsp: mixins --> mixings? (ff) (or is here really the object meant?)
whenever the shading is used, \pgfname\ first converts the colors in the
list to \textsc{rgb} triples using the current values of the
colors and taking any mixins and blends into account. If the
resulting \textsc{rgb} triples have not yet been used, a new
shading is internally created and used. Note that if the
option \meta{color list} is used, then no shading is created until
the first use of |\pgfuseshading|. In particular, the colors
mentioned in the shading need not be defined when the declaration is
given.
You can also position labels on curves and, by adding the |sloped|
option, have them rotated such that they match the line's slope. Here
is an example:
\begin{codeexample}[]
\begin{tikzpicture}
\draw (0,0) .. controls (6,1) and (9,1) ..
node[near start,sloped,above] {near start}
node {midway}
node[very near end,sloped,below] {very near end} (12,0);
\end{tikzpicture}
\end{codeexample}

If you have a copy of pgfmanual-en-main-preamble.tex as well, you can change the line
\input{../../macros/pgfmanual-en-macros} % TODOsp: same here
to
\input{pgfmanual-en-macros} % TODOsp: same here
unless you put the file in the right place. And then
\documentclass{ltxdoc}
\input pgfmanual-en-main-preamble.tex
% change the line
% \input{../../macros/pgfmanual-en-macros}
% to
% \input{pgfmanual-en-macros}
Same content as before, except that pgfmanual-en-main-preamble.tex prepares more commands and settings. (For instance the command environment, layout, and the \setlength.)
\begin{document}
\subsubsection{Horizontal and Vertical Shadings}
\begin{command}{\pgfdeclarehorizontalshading\oarg{color list}\marg{shading
name}\marg{shading height}\marg{color specification}}
Declares a horizontal shading named \meta{shading name} of the specified
\meta{height} with the specified colors. The width of the bar is
deduced automatically from the maximum dimension in the specification.
\begin{codeexample}[]
\pgfdeclarehorizontalshading{myshadingA}
{1cm}{rgb(0cm)=(1,0,0); color(2cm)=(green); color(4cm)=(blue)}
\pgfuseshading{myshadingA}
\end{codeexample}
The effect of the \meta{color list}, which is a
comma-separated list of colors, is the following: Normally, when
this list is empty, once a shading has been declared, it becomes
``frozen.'' This means that even if you change a color that was used
in the declaration of the shading later on, the shading will not
change. By specifying a \meta{color list} you can specify
that the shading should be recalculated whenever one of the colors
listed in the list changes (this includes effects like color
mixins). Thus, when you specify a \meta{color list}, % TODOsp: mixins --> mixings? (ff) (or is here really the object meant?)
whenever the shading is used, \pgfname\ first converts the colors in the
list to \textsc{rgb} triples using the current values of the
colors and taking any mixins and blends into account. If the
resulting \textsc{rgb} triples have not yet been used, a new
shading is internally created and used. Note that if the
option \meta{color list} is used, then no shading is created until
the first use of |\pgfuseshading|. In particular, the colors
mentioned in the shading need not be defined when the declaration is
given.
\end{command}
You can also position labels on curves and, by adding the |sloped|
option, have them rotated such that they match the line's slope. Here
is an example:
\begin{codeexample}[]
\begin{tikzpicture}
\draw (0,0) .. controls (6,1) and (9,1) ..
node[near start,sloped,above] {near start}
node {midway}
node[very near end,sloped,below] {very near end} (12,0);
\end{tikzpicture}
\end{codeexample}
\end{document}

verbatimsolution acceptable? – Steven B. Segletes Nov 30 '15 at 18:23tikzpictureand again inside a listing)? – Steven B. Segletes Nov 30 '15 at 18:28expliciturpictureas far as I can but it would not break the line: http://i.stack.imgur.com/Q84qH.png – Pawel Gumiela Dec 01 '15 at 07:13