Files
klammertext/mac/target_registry.h
Andy Kopra 6e7596ab2e Option sets: a .o target for shared parameters
A named group of optional parameters, declared once and used by several
klammers, so a writer learns one vocabulary instead of a spelling per
klammer.  The "o" target is a pseudo-target beside "k": "k" declares a
klammer's interface and documents it, "o" declares an option interface and
documents it, and neither produces output for any target.

    @@caption_args.o :caption :number.bool true :caption_side.side
    : Arguments that define a caption for a block element @@

    @@code.k :filename @hpos_args :hpos left @ @caption_args :caption_side top @
    | text.literal : A source file displayed verbatim @@

A set is used only in the parameter list of a ".k" declaration -- the one
place a klammer's interface is declared once for all of its targets -- and
is resolved as that list is read.  Names and types come from the set; a
default may be overridden where it is used.  A klammer application in a
parameter list is now a definition-time error.

The SKS gains the sets caption_args and hpos_args (:hpos and :offset), and
@table, @image, @image_grid, @reference and @show gain .k declarations.  A
distance is no longer written as a position: :hpos 4em is rejected, and the
same layout is :hpos left :offset 4em.  Code listings are numbered by
default, like tables and figures.

New engine sources mac/option_set{,_registry}.{h,cpp}; tst/ ships two more
suites, option_set_test.sh and signature_test.sh (twelve in all).

 (from dev 34e536cb0329)
2026-08-06 13:11:37 +02:00

78 lines
2.4 KiB
C++

#pragma once
#include <map>
#include <string>
#include "target.h"
#include "argument_set.h"
#include "katom.h"
class Target_registry
{
public:
static std::string declare_name;
static std::string general_name;
// The pseudo-target of an option set declaration (@@name.o), reserved in
// the target namespace exactly as "k" is: both declare an interface and
// document it, and neither produces output for any target.
static std::string optionset_name;
Target_registry();
void add(Target target);
void add(std::vector<Katom>::iterator begin, std::vector<Katom>::iterator end, std::vector<Katom>& katoms);
void check_for_previous_definition(const std::string& name, const Locator& loc) const;
/*
void add_transforms(std::string target_name, std::string transforms);
void add_transforms(
std::string target_name,
std::vector<std::pair<std::string, std::string>> transforms);
*/
bool has(const std::string& target_name) const;
Target get(const std::string& target_name, const Locator& loc) const;
void transform(const std::string& target_name, std::vector<Katom>& katoms) const;
std::vector<std::string> user_defined() const;
std::vector<std::string> applicable() const;
std::string describe(int margin=2, bool long_format=false) const;
//Argtype_registry m_argtypes {};
std::map<std::string, Target> m_targets {};
std::vector<std::string> m_names {};
Parameter_set m_parameters {};
/*
std::string m_parameters_spec {"name | desc :after_apply :after_write :includes | transforms.rest"};
Parameter_set m_parameters =
katomize(line_split(m_parameters_spec), Locator().str());
*/
//Parameter_set m_parameters =
// Parameter_set(katomize({"name :desc | transforms.rest"}, "target_registry"));
/*
// Targets(Statevar_set& statevars);
target_ptr check_target_existence(
std::string name, Locator loc, bool should_exist);
void add(std::string name, std::string desc, std::string include,
// Statevar_set& statevars,
std::string transform,
std::string before_apply, std::string after_apply, std::string after_write,
Locator loc);
target_ptr check_target_name(
std::string target, bool allow_all, Locator loc);
std::map<std::string, target_ptr> targets {};
std::vector<std::string> names {};
void describe_suffixes();
void describe();
*/
};