mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibManual: Add SubsectionNode
This commit is contained in:
parent
2aa374eba1
commit
a9fe80550d
Notes:
sideshowbarker
2024-07-17 07:25:39 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/a9fe80550d Pull-request: https://github.com/SerenityOS/serenity/pull/16495 Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 54 additions and 0 deletions
|
@ -3,6 +3,7 @@ set(SOURCES
|
|||
PageNode.cpp
|
||||
Path.cpp
|
||||
SectionNode.cpp
|
||||
SubsectionNode.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibManual manual)
|
||||
|
|
26
Userland/Libraries/LibManual/SubsectionNode.cpp
Normal file
26
Userland/Libraries/LibManual/SubsectionNode.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "SubsectionNode.h"
|
||||
|
||||
namespace Manual {
|
||||
|
||||
SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView name)
|
||||
: SectionNode(name, name)
|
||||
, m_parent(move(parent))
|
||||
{
|
||||
}
|
||||
|
||||
Node const* SubsectionNode::parent() const { return m_parent; }
|
||||
|
||||
ErrorOr<String> SubsectionNode::name() const { return m_name; }
|
||||
|
||||
ErrorOr<String> SubsectionNode::path() const
|
||||
{
|
||||
return String::formatted("{}/{}", TRY(m_parent->path()), m_section);
|
||||
}
|
||||
|
||||
}
|
27
Userland/Libraries/LibManual/SubsectionNode.h
Normal file
27
Userland/Libraries/LibManual/SubsectionNode.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibManual/SectionNode.h>
|
||||
|
||||
namespace Manual {
|
||||
|
||||
// A non-toplevel (i.e. not numbered) manual section.
|
||||
class SubsectionNode : public SectionNode {
|
||||
public:
|
||||
SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView name);
|
||||
virtual ~SubsectionNode() = default;
|
||||
|
||||
virtual Node const* parent() const override;
|
||||
virtual ErrorOr<String> path() const override;
|
||||
virtual ErrorOr<String> name() const override;
|
||||
|
||||
protected:
|
||||
NonnullRefPtr<SectionNode> m_parent;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue