% !TeX program = lualatex
\documentclass{article}
\ProvidesFile{docref.tex}[2026/10/26 v0.2 docref manual]
\usepackage{iftex}
\ifLuaTeX\else
  \PackageError{docref manual}{LuaLaTeX is required}{Compile this manual with LuaLaTeX.}
\fi

\usepackage{pkgmeta}
\usepackage{datemultical}
\dmcset{docref}{\pkgmeta[year]{docref}}{\pkgmeta[month]{docref}}{\pkgmeta[day]{docref}}
\usepackage{docref}
\usepackage[colorlinks]{hyperref}
\DocRefSource{geometry}{geometry-labels.aux}[geometry.pdf]

\title{The \texttt{docref} Package}
\author{Amer Amikhteh}
\date{Version \pkgmeta[version]{docref}\\[2pt]\dmc{docref}{long}}

\begin{document}
\maketitle

\begin{abstract}
    \noindent\texttt{docref} retrieves reference numbers, titles, and page numbers
    from locally available package documentation. It requires LuaLaTeX.
    Keep \texttt{docref.sty} and \texttt{docref.lua} together beside your document
    or in a TeX-searchable directory.
\end{abstract}

\section{Usage}\label{sec:hyperlinks}
Each command takes a package name and a label.
\verb|\docref{pkg}{label}| gives the reference number,
\verb|\docnameref{pkg}{label}| the title or caption, and
\verb|\docpageref{pkg}{label}| the page number.

For example, refer to a section in the Babel manual:
\begin{verbatim}
\usepackage{docref}
\usepackage{hyperref} % optional

See Section~\docref{babel}{selectors},
``\docnameref{babel}{selectors}'',
on page~\docpageref{babel}{selectors}.
\end{verbatim}

This refers to Babel section~\docref{babel}{selectors},
``\docnameref{babel}{selectors}'', on page~\docpageref{babel}{selectors}.

The same commands work for figures. This example uses the supplied label
record from the \texttt{geometry}~6.0 manual:
\begin{verbatim}
\DocRefSource{geometry}{geometry-labels.aux}[geometry.pdf]

Figure~\docref{geometry}{fig:Labc},
``\docnameref{geometry}{fig:Labc}'',
on page~\docpageref{geometry}{fig:Labc}.
\end{verbatim}

This refers to Figure~\docref{geometry}{fig:Labc},
``\docnameref{geometry}{fig:Labc}'', on page~\docpageref{geometry}{fig:Labc}.

With \textsf{hyperref}, loaded before or after \texttt{docref}, references
link to the external PDF. All three commands accept a star to suppress the
link, for example \verb|\docref*{geometry}{fig:Labc}|.
Unresolved values produce \texttt{??} and a warning.
Dotted number components follow the surrounding text direction; digits
within each component remain left to right.

\section{Selecting a manual}
Common source names include \texttt{pkg.tex}, \texttt{pkg-doc.tex}, and
\texttt{pkg-manual.tex}; \texttt{.ltx} and \texttt{.dtx} sources are also
supported. Installed documentation takes precedence over similarly named
files in the working directory.

Register a source or auxiliary file explicitly in the preamble:
\begin{verbatim}
\DocRefSource{pkg}{path/manual.tex}[path/manual.pdf]
\end{verbatim}
The optional final argument selects a PDF file or URL. Otherwise the PDF
is sought beside the source and in TeX's documentation search path.
A fragment's \verb|% !TeX root = manual.tex| comment selects its main
document. An auxiliary file can be registered without the TeX source.

\section{Labels and lookup rules}
For complete references, make the built manual's \texttt{.aux} file
available. Its records supply numbers, titles, pages, and destinations for
all label types, including chapters, figures, tables, equations, list items,
and custom counters.

Titles require records produced with \textsf{nameref} or \textsf{hyperref};
exact link destinations require \textsf{hyperref} in the target manual.
Titles are plain text; recorded empty values remain empty. Auxiliary files,
including those for included chapters, are read as data.

Source scanning alone handles headings from \texttt{section} to
\texttt{subparagraph}, with labels following their headings.
It cannot calculate arbitrary counters or pagination. PDF bookmarks and
page labels provide fallback titles and pages; physical page numbers are
used when page labels are absent.

Without an auxiliary destination, a standard section destination is used
only if it exists in the PDF; otherwise the link opens the manual at its
beginning. If no PDF is found, the reference remains unlinked.

\section{License}

The \texttt{Docref} package is released under the
\LaTeX~Project Public License (LPPL),
version 1.3c or later.
The full text of the license is available in the \texttt{LICENSE} file.

\section{Author and Maintainer}

The \texttt{Docref} package is developed and maintained by
\textbf{Amer Amikhteh}.

The project's source code, development versions, and issue tracker are
available in the project repository:

\begin{center}
    \url{https://github.com/gambi-shah/docref}
\end{center}

\end{document}
