Skip to content

Commit

Permalink
Display the private ticket footnote only when enabled in project; #24
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchane committed Oct 27, 2023
1 parent 1d8cf88 commit 5ff96c7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/footnote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn is_footnote_defined(project: &Path) -> Result<bool> {
}
}

log::info!("The private ticket footnote is not defined.");
Ok(false)
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ impl Document {
&tickets_for_internal,
&project.templates,
DocumentVariant::Internal,
project.private_footnote,
);
let external_modules = templating::format_document(
&tickets_for_external,
&project.templates,
DocumentVariant::External,
project.private_footnote,
);

let (status_table, json_status) = status_report::analyze_status(&abstract_tickets)?;
Expand Down
8 changes: 4 additions & 4 deletions src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::ticket_abstraction::AbstractTicket;
impl AbstractTicket {
/// Compose a release note from an abstract ticket.
#[must_use]
pub fn release_note(&self, variant: DocumentVariant) -> String {
pub fn release_note(&self, variant: DocumentVariant, with_priv_footnote: bool) -> String {
let anchor = self.anchor_declaration();

// This debug information line appears at empty release notes
Expand Down Expand Up @@ -51,7 +51,7 @@ impl AbstractTicket {
"{}\n{}\n\n{} {}",
anchor,
doc_text_unix,
self.all_signatures(),
self.all_signatures(with_priv_footnote),
// In the internal variant, add the debug information line.
if variant == DocumentVariant::Internal {
&debug_info
Expand Down Expand Up @@ -89,8 +89,8 @@ impl AbstractTicket {
/// Prepare a list with signatures to this ticket and all its optional references.
/// The result is a comma-separated list of signatures, enclosed in parentheses.
#[must_use]
fn all_signatures(&self) -> String {
let mut signatures = vec![self.signature(true)];
fn all_signatures(&self, with_priv_footnote: bool) -> String {
let mut signatures = vec![self.signature(with_priv_footnote)];

if let Some(references) = self.references.as_ref() {
signatures.append(&mut references.clone());
Expand Down
11 changes: 7 additions & 4 deletions src/templating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl config::Section {
id: &str,
tickets: &[&AbstractTicket],
variant: DocumentVariant,
with_priv_footnote: bool,
ticket_stats: &mut HashMap<Rc<TicketId>, u32>,
) -> Option<String> {
let matching_tickets: Vec<_> = tickets.iter().filter(|t| self.matches_ticket(t)).collect();
Expand All @@ -178,7 +179,7 @@ impl config::Section {
} else {
let release_notes: Vec<_> = matching_tickets
.iter()
.map(|t| t.release_note(variant))
.map(|t| t.release_note(variant, with_priv_footnote))
.collect();

let template = Leaf {
Expand Down Expand Up @@ -206,6 +207,7 @@ impl config::Section {
tickets: &[&AbstractTicket],
prefix: Option<&str>,
variant: DocumentVariant,
with_priv_footnote: bool,
ticket_stats: &mut HashMap<Rc<TicketId>, u32>,
) -> Option<Module> {
let matching_tickets: Vec<&AbstractTicket> = tickets
Expand All @@ -227,7 +229,7 @@ impl config::Section {
let included_modules: Vec<Module> = sections
.iter()
.filter_map(|s| {
s.modules(&matching_tickets, Some(&module_id), variant, ticket_stats)
s.modules(&matching_tickets, Some(&module_id), variant, with_priv_footnote, ticket_stats)
})
.collect();
// If the assembly receives no modules, because all its modules are empty, return None.
Expand Down Expand Up @@ -261,7 +263,7 @@ impl config::Section {
} else {
// If the module receives no release notes and its body is empty, return None.
// Otherwise, return the module formatted with its release notes.
self.render(&module_id, tickets, variant, ticket_stats)
self.render(&module_id, tickets, variant, with_priv_footnote, ticket_stats)
.map(|text| Module {
file_name: format!("ref_{module_id}.adoc"),
text,
Expand Down Expand Up @@ -335,6 +337,7 @@ pub fn format_document(
tickets: &[&AbstractTicket],
template: &config::Template,
variant: DocumentVariant,
with_priv_footnote: bool,
) -> Vec<Module> {
// Prepare a container for ticket usage statistics.
let mut ticket_stats = HashMap::new();
Expand All @@ -354,7 +357,7 @@ pub fn format_document(
let chapters: Vec<_> = template
.chapters
.iter()
.filter_map(|section| section.modules(tickets, None, variant, &mut ticket_stats))
.filter_map(|section| section.modules(tickets, None, variant, with_priv_footnote, &mut ticket_stats))
.collect();
log::debug!("Chapters: {:#?}", chapters);

Expand Down

0 comments on commit 5ff96c7

Please sign in to comment.