1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:05:08 +00:00
serenity/Userland/Libraries/LibManual/PageNode.cpp
kleines Filmröllchen 5a346c4297 Help+LibManual: Without arguments, open index page instead of crashing
This is the old behavior before the recent LibManual refactor. It also
moves the definition of the index page into LibManual for better reuse.
2022-12-12 00:37:29 -07:00

36 lines
837 B
C++

/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "PageNode.h"
#include "SectionNode.h"
#include <AK/RefPtr.h>
namespace Manual {
Node const* PageNode::parent() const
{
return m_section.ptr();
}
NonnullRefPtrVector<Node>& PageNode::children() const
{
static NonnullRefPtrVector<Node> empty_vector;
return empty_vector;
}
ErrorOr<String> PageNode::path() const
{
return TRY(String::formatted("{}/{}.md", TRY(m_section->path()), m_page));
}
ErrorOr<NonnullRefPtr<PageNode>> PageNode::help_index_page()
{
static NonnullRefPtr<PageNode> const help_index_page = TRY(try_make_ref_counted<PageNode>(sections[7 - 1], TRY(String::from_utf8("Help-index"sv))));
return help_index_page;
}
}