mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-24 22:32:06 +00:00 
			
		
		
		
	 10700ca4c1
			
		
	
	
		10700ca4c1
		
	
	
	
	
		
			
			For a subsection named `Foo` with a markdown file `Foo.md` in the same directory, the document `Foo.md` will be returned when the subsection is selected. This prevents PageNodes and SubsectionNodes from sharing the same name, which fixes an issue in Help where subsections could not be navigated.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			750 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			750 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include "SubsectionNode.h"
 | |
| #include "PageNode.h"
 | |
| #include <AK/TypeCasts.h>
 | |
| 
 | |
| namespace Manual {
 | |
| 
 | |
| SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode const> parent, StringView name, RefPtr<PageNode> page)
 | |
|     : SectionNode(name, name)
 | |
|     , m_parent(move(parent))
 | |
|     , m_page(move(page))
 | |
| {
 | |
| }
 | |
| 
 | |
| Node const* SubsectionNode::parent() const { return m_parent; }
 | |
| 
 | |
| PageNode const* SubsectionNode::document() const { return m_page; }
 | |
| 
 | |
| ErrorOr<String> SubsectionNode::name() const { return m_name; }
 | |
| 
 | |
| ErrorOr<String> SubsectionNode::path() const
 | |
| {
 | |
|     return String::formatted("{}/{}", TRY(m_parent->path()), m_section);
 | |
| }
 | |
| 
 | |
| }
 |